From 9accfdab6f48daa9dbe47de84f0bda84d4103546 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 16 Sep 2014 22:04:10 +0200 Subject: ACCESS: Implement mWhile2 and plotInactive, change _inactive from Resource* to ImageEntry --- engines/access/access.cpp | 10 ++-- engines/access/access.h | 2 +- engines/access/amazon/amazon_game.h | 2 +- engines/access/amazon/amazon_room.cpp | 4 +- engines/access/amazon/amazon_scripts.cpp | 96 +++++++++++++++++++++++++++++++- engines/access/amazon/amazon_scripts.h | 2 + engines/access/martian/martian_room.cpp | 4 +- 7 files changed, 109 insertions(+), 11 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 55af992dbb..5636654d03 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -55,7 +55,9 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _mouseMode = 0; _currentMan = 0; _currentManOld = -1; - _inactive = nullptr; + _inactive._spritesPtr = nullptr; + _inactive._flags = _inactive._frameNumber = _inactive._offsetY = 0; + _inactive._position = Common::Point(0, 0); _music = nullptr; _title = nullptr; _converseMode = 0; @@ -127,7 +129,7 @@ AccessEngine::~AccessEngine() { delete _video; freeCells(); - delete _inactive; + delete _inactive._spritesPtr; delete _music; delete _title; delete _eseg; @@ -212,8 +214,8 @@ void AccessEngine::freeCells() { } void AccessEngine::freeInactiveData() { - delete _inactive; - _inactive = nullptr; + delete _inactive._spritesPtr; + _inactive._spritesPtr = nullptr; } void AccessEngine::speakText(ASurface *s, Common::Array msgArr) { diff --git a/engines/access/access.h b/engines/access/access.h index 42ba49fd5d..157a33c723 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -171,7 +171,7 @@ public: int _mouseMode; int _currentManOld; - Resource *_inactive; + ImageEntry _inactive; Resource *_music; Resource *_title; int _converseMode; diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index d0f1b2d043..0275ceec17 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -65,7 +65,6 @@ private: int _topList; int _botList; int _riverIndex; - int _inactiveYOff; int _esTabTable[100]; // Other fields @@ -116,6 +115,7 @@ public: int _rawInactiveX; int _rawInactiveY; + int _inactiveYOff; // Fields that are mapped to flags int &_guardLocation; diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index 227fc474cf..39cea9ae62 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -77,7 +77,9 @@ void AmazonRoom::reloadRoom() { void AmazonRoom::reloadRoom1() { if (_vm->_player->_roomNumber == 29 || _vm->_player->_roomNumber == 31 || _vm->_player->_roomNumber == 42 || _vm->_player->_roomNumber == 44) { - _vm->_inactive = _vm->_files->loadFile("MAYA.LZ"); + Resource *spriteData = _vm->_files->loadFile("MAYA.LZ"); + _vm->_inactive._spritesPtr = new SpriteResource(_vm, spriteData); + delete spriteData; _vm->_currentCharFlag = false; } diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 4439a287c3..8c172334a5 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -153,10 +153,62 @@ void AmazonScripts::mWhile1() { } while (_vm->_flags[52] == 4); } +void AmazonScripts::mWhile2() { + _vm->_screen->setDisplayScan(); + _vm->_screen->fadeOut(); + _vm->_events->hideCursor(); + + _vm->_files->loadScreen(14, 0); + _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_events->showCursor(); + + _vm->_screen->setIconPalette(); + _vm->_screen->forceFadeIn(); + + Resource *spriteData = _vm->_files->loadFile(14, 6); + _vm->_objectsTable[0] = new SpriteResource(_vm, spriteData); + delete spriteData; + + _vm->_images.clear(); + _vm->_oldRects.clear(); + _sequence = 2100; + + do { + cLoop(); + _sequence = 2100; + } while (_vm->_flags[52] == 1); + + _vm->_screen->fadeOut(); + _vm->freeCells(); + spriteData = _vm->_files->loadFile(14, 9); + _vm->_objectsTable[3] = new SpriteResource(_vm, spriteData); + delete spriteData; + + _vm->_screen->setDisplayScan(); + _vm->_events->hideCursor(); + + _vm->_files->loadScreen(14, 3); + _vm->_screen->setPalette(); + _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_events->showCursor(); + + _vm->_screen->setIconPalette(); + _vm->_images.clear(); + _vm->_oldRects.clear(); + _sequence = 2400; + + do { + cLoop(); + _sequence = 2400; + } while (_vm->_flags[52] == 4); +} + void AmazonScripts::mWhile(int param1) { switch(param1) { case 1: - warning("TODO MWHILE1"); + mWhile1(); break; case 2: warning("TODO FLY"); @@ -174,7 +226,7 @@ void AmazonScripts::mWhile(int param1) { warning("TODO DOWNRIVER"); break; case 7: - warning("TODO MWHILE2"); + mWhile2(); break; case 8: warning("TODO JWALK2"); @@ -212,6 +264,44 @@ void AmazonScripts::boatWalls(int param1, int param2) { } } +void AmazonScripts::plotInactive() { + if (_game->_charSegSwitch) { + _game->_currentCharFlag = true; + SpriteResource *tmp = _vm->_inactive._spritesPtr; + _vm->_inactive._spritesPtr = _vm->_player->_playerSprites; + _vm->_player->_playerSprites = tmp; + _game->_charSegSwitch = false; + } else if (_game->_jasMayaFlag != _game->_currentCharFlag) { + if (_vm->_player->_playerOff) { + _game->_jasMayaFlag = _game->_currentCharFlag; + } else { + _game->_currentCharFlag = _game->_jasMayaFlag; + int tmpX = _game->_rawInactiveX; + int tmpY = _game->_rawInactiveY; + _game->_rawInactiveX = _vm->_player->_rawPlayer.x; + _game->_rawInactiveY = _vm->_player->_rawPlayer.y; + _vm->_player->_rawPlayer.x = tmpX; + _vm->_player->_rawPlayer.y = tmpY; + _game->_inactiveYOff = _vm->_player->_playerOffset.y; + _vm->_player->calcManScale(); + } + } + + if (_vm->_player->_roomNumber == 44) { + warning("CHECKME: Only sets useless(?) flags 155 and 160"); + } + + _vm->_inactive._flags &= 0xFD; + _vm->_inactive._flags &= 0xF7; + _vm->_inactive._position.x = _game->_rawInactiveX; + _vm->_inactive._position.y = _game->_rawInactiveY - _game->_inactiveYOff; + _vm->_inactive._offsetY = _game->_inactiveYOff; + _vm->_inactive._frameNumber = 0; + + _vm->_images.addToList(&_vm->_inactive); + +} + void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { switch (commandIndex) { case 1: @@ -236,7 +326,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { warning("TODO NEWMUSIC"); break; case 11: - warning("TODO PLOTINACTIVE"); + plotInactive(); break; case 13: warning("TODO RIVER"); diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 735606f1da..7afa0ea577 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -41,8 +41,10 @@ protected: void cLoop(); void mWhile1(); + void mWhile2(); void mWhile(int param1); void loadBackground(int param1, int param2); + void plotInactive(); void setInactive(); void boatWalls(int param1, int param2); diff --git a/engines/access/martian/martian_room.cpp b/engines/access/martian/martian_room.cpp index 52eead7c0b..e624b0abd5 100644 --- a/engines/access/martian/martian_room.cpp +++ b/engines/access/martian/martian_room.cpp @@ -75,7 +75,9 @@ void MartianRoom::reloadRoom() { void MartianRoom::reloadRoom1() { if (_vm->_player->_roomNumber == 29 || _vm->_player->_roomNumber == 31 || _vm->_player->_roomNumber == 42 || _vm->_player->_roomNumber == 44) { - _vm->_inactive = _vm->_files->loadFile("MAYA.LZ"); + Resource *spriteData = _vm->_files->loadFile("MAYA.LZ"); + _vm->_inactive._spritesPtr = new SpriteResource(_vm, spriteData); + delete spriteData; _vm->_currentCharFlag = false; } -- cgit v1.2.3