diff options
author | Paul Gilbert | 2016-08-17 22:15:05 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-08-17 22:15:05 -0400 |
commit | bf5835b0dcd8134a82221804be0eb6c415adeeb5 (patch) | |
tree | 5c20cb3f28fc1b4c68f1138aa3969028366bb34b /engines/titanic/game | |
parent | 41dab514e1f7dc4bbf9ff9bab21c5dc5cad7812f (diff) | |
download | scummvm-rg350-bf5835b0dcd8134a82221804be0eb6c415adeeb5.tar.gz scummvm-rg350-bf5835b0dcd8134a82221804be0eb6c415adeeb5.tar.bz2 scummvm-rg350-bf5835b0dcd8134a82221804be0eb6c415adeeb5.zip |
TITANIC: Implementing game logic classes
Diffstat (limited to 'engines/titanic/game')
-rw-r--r-- | engines/titanic/game/cell_point_button.cpp | 34 | ||||
-rw-r--r-- | engines/titanic/game/cell_point_button.h | 7 | ||||
-rw-r--r-- | engines/titanic/game/chev_code.cpp | 135 | ||||
-rw-r--r-- | engines/titanic/game/chev_code.h | 15 | ||||
-rw-r--r-- | engines/titanic/game/sgt/chest_of_drawers.cpp | 43 | ||||
-rw-r--r-- | engines/titanic/game/sgt/chest_of_drawers.h | 4 |
6 files changed, 227 insertions, 11 deletions
diff --git a/engines/titanic/game/cell_point_button.cpp b/engines/titanic/game/cell_point_button.cpp index 18ece09cb0..207dd73543 100644 --- a/engines/titanic/game/cell_point_button.cpp +++ b/engines/titanic/game/cell_point_button.cpp @@ -24,12 +24,17 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CCellPointButton, CBackground) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(EnterViewMsg) +END_MESSAGE_MAP() + CCellPointButton::CCellPointButton() : CBackground() { _fieldE0 = 0; _fieldE4 = 0; _fieldE8 = 0; _fieldEC = 0; - _fieldF0 = 0; + _regionNum = 0; _fieldF4 = 0; _fieldF8 = 0; _fieldFC = 0; @@ -44,7 +49,7 @@ void CCellPointButton::save(SimpleFile *file, int indent) { file->writeNumberLine(_fieldE4, indent); file->writeNumberLine(_fieldE8, indent); file->writeNumberLine(_fieldEC, indent); - file->writeNumberLine(_fieldF0, indent); + file->writeNumberLine(_regionNum, indent); file->writeNumberLine(_fieldF4, indent); file->writeNumberLine(_fieldF8, indent); file->writeNumberLine(_fieldFC, indent); @@ -52,7 +57,7 @@ void CCellPointButton::save(SimpleFile *file, int indent) { file->writeNumberLine(_field104, indent); file->writeNumberLine(_field108, indent); file->writeQuotedLine(_string3, indent); - file->writeNumberLine(_field118, indent); + file->writeNumberLine(_dialNum, indent); CBackground::save(file, indent); } @@ -63,7 +68,7 @@ void CCellPointButton::load(SimpleFile *file) { _fieldE4 = file->readNumber(); _fieldE8 = file->readNumber(); _fieldEC = file->readNumber(); - _fieldF0 = file->readNumber(); + _regionNum = file->readNumber(); _fieldF4 = file->readNumber(); _fieldF8 = file->readNumber(); _fieldFC = file->readNumber(); @@ -71,9 +76,28 @@ void CCellPointButton::load(SimpleFile *file) { _field104 = file->readNumber(); _field108 = file->readNumber(); _string3 = file->readString(); - _field118 = file->readNumber(); + _dialNum = file->readNumber(); CBackground::load(file); } +bool CCellPointButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (getRandomNumber(2) == 0) { + CParrotSpeakMsg speakMsg("Cellpoints", _string3); + speakMsg.execute("PerchedParrot"); + } + + playMovie(0); + _regionNum = _regionNum ? 0 : 1; + playSound("z#425.wav"); + talkSetDialRegion(_string3, _dialNum, _regionNum); + + return true; +} + +bool CCellPointButton::EnterViewMsg(CEnterViewMsg *msg) { + _regionNum = talkGetDialRegion(_string3, _dialNum); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/cell_point_button.h b/engines/titanic/game/cell_point_button.h index 6f1fdc3809..33f58cbb83 100644 --- a/engines/titanic/game/cell_point_button.h +++ b/engines/titanic/game/cell_point_button.h @@ -28,12 +28,15 @@ namespace Titanic { class CCellPointButton : public CBackground { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); public: int _fieldE0; int _fieldE4; int _fieldE8; int _fieldEC; - int _fieldF0; + int _regionNum; int _fieldF4; int _fieldF8; int _fieldFC; @@ -41,7 +44,7 @@ public: int _field104; int _field108; CString _string3; - int _field118; + int _dialNum; public: CLASSDEF; CCellPointButton(); diff --git a/engines/titanic/game/chev_code.cpp b/engines/titanic/game/chev_code.cpp index ebc20578b7..4dd3ac3d4a 100644 --- a/engines/titanic/game/chev_code.cpp +++ b/engines/titanic/game/chev_code.cpp @@ -24,16 +24,147 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CChevCode, CGameObject) + ON_MESSAGE(SetChevLiftBits) + ON_MESSAGE(SetChevClassBits) + ON_MESSAGE(SetChevFloorBits) + ON_MESSAGE(SetChevRoomBits) + ON_MESSAGE(GetChevLiftNum) + ON_MESSAGE(GetChevClassNum) + ON_MESSAGE(GetChevFloorNum) + ON_MESSAGE(GetChevRoomNum) + ON_MESSAGE(CheckChevCode) + ON_MESSAGE(GetChevCodeFromRoomNameMsg) +END_MESSAGE_MAP() + void CChevCode::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_value, indent); + file->writeNumberLine(_floorBits, indent); CGameObject::save(file, indent); } void CChevCode::load(SimpleFile *file) { file->readNumber(); - _value = file->readNumber(); + _floorBits = file->readNumber(); CGameObject::load(file); } +bool CChevCode::SetChevLiftBits(CSetChevLiftBits *msg) { + _floorBits &= ~0xC0000; + if (msg->_liftNum > 0 && msg->_liftNum < 5) + _floorBits = ((msg->_liftNum - 1) << 18) | _floorBits; + + return true; +} + +bool CChevCode::SetChevClassBits(CSetChevClassBits *msg) { + _floorBits &= ~0x30000; + if (msg->_classNum > 0 && msg->_classNum < 4) + _floorBits = (msg->_classNum << 16) | msg->_classNum; + + return true; +} + +bool CChevCode::SetChevFloorBits(CSetChevFloorBits *msg) { + int section = (msg->_floorNum + 4) / 10; + int index = (msg->_floorNum + 4) % 10; + _floorBits &= ~0xFF00; + + int val; + switch (section) { + case 0: + val = 144; + break; + case 1: + val = 208; + break; + case 2: + val = 224; + break; + case 3: + val = 240; + break; + default: + break; + } + + _floorBits |= ((index + val) << 8); + return true; +} + +bool CChevCode::SetChevRoomBits(CSetChevRoomBits *msg) { + _floorBits &= ~0xff; + if (msg->_roomNum > 0 && msg->_roomNum < 128) + _floorBits |= msg->_roomNum * 2; + + return true; +} + +bool CChevCode::GetChevLiftNum(CGetChevLiftNum *msg) { + msg->_liftNum = (_floorBits >> 18) & 3 + 1; + return true; +} + +bool CChevCode::GetChevClassNum(CGetChevClassNum *msg) { + msg->_classNum = (_floorBits >> 16) & 3; + return true; +} + +bool CChevCode::GetChevFloorNum(CGetChevFloorNum *msg) { + int val1 = (_floorBits >> 8) & 0xF; + int val2 = (_floorBits >> 12) & 0xF - 9; + + switch (val2) { + case 0: + val2 = 0; + break; + case 4: + val2 = 1; + break; + case 5: + val2 = 2; + break; + case 6: + val2 = 3; + break; + default: + val2 = 4; + break; + } + + msg->_floorNum = (val1 >= 10) ? 0 : val1 * 10; + return true; +} + +bool CChevCode::GetChevRoomNum(CGetChevRoomNum *msg) { + msg->_roomNum = (_floorBits >> 1) & 0x7F; + return true; +} + +bool CChevCode::CheckChevCode(CCheckChevCode *msg) { + // TODO + return true; +} + +bool CChevCode::GetChevCodeFromRoomNameMsg(CGetChevCodeFromRoomNameMsg *msg) { + static const char *const ROOM_NAMES[13] = { + "ParrotLobby", "sculptureChamber", "Bar", "EmbLobby", "MusicRoom", + "Titania", "BottomOfWell", "Arboretum", "PromenadeDeck", + "FCRestrnt", "CrtrsCham", "BilgeRoom", "Bridge" + }; + static const uint CHEV_CODES[13] = { + 0x1D0D9, 0x465FB, 0xB3D97, 0xCC971, 0xF34DB, 0x8A397, 0x59FAD, + 0x4D6AF, 0x79C45, 0x196D9, 0x2F86D, 0x3D94B, 0x39FCB + }; + + for (int idx = 0; idx < 13; ++idx) { + if (msg->_roomName == ROOM_NAMES[idx]) { + msg->_chevCode = CHEV_CODES[idx]; + break; + } + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/chev_code.h b/engines/titanic/game/chev_code.h index c4552d00a2..88b26cd6ec 100644 --- a/engines/titanic/game/chev_code.h +++ b/engines/titanic/game/chev_code.h @@ -28,11 +28,22 @@ namespace Titanic { class CChevCode : public CGameObject { + DECLARE_MESSAGE_MAP; + bool SetChevLiftBits(CSetChevLiftBits *msg); + bool SetChevClassBits(CSetChevClassBits *msg); + bool SetChevFloorBits(CSetChevFloorBits *msg); + bool SetChevRoomBits(CSetChevRoomBits *msg); + bool GetChevLiftNum(CGetChevLiftNum *msg); + bool GetChevClassNum(CGetChevClassNum *msg); + bool GetChevFloorNum(CGetChevFloorNum *msg); + bool GetChevRoomNum(CGetChevRoomNum *msg); + bool CheckChevCode(CCheckChevCode *msg); + bool GetChevCodeFromRoomNameMsg(CGetChevCodeFromRoomNameMsg *msg); public: - int _value; + int _floorBits; public: CLASSDEF; - CChevCode() : CGameObject(), _value(0) {} + CChevCode() : CGameObject(), _floorBits(0) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/sgt/chest_of_drawers.cpp b/engines/titanic/game/sgt/chest_of_drawers.cpp index be62e12c8e..d9c72d3021 100644 --- a/engines/titanic/game/sgt/chest_of_drawers.cpp +++ b/engines/titanic/game/sgt/chest_of_drawers.cpp @@ -24,6 +24,12 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CChestOfDrawers, CSGTStateRoom) + ON_MESSAGE(TurnOn) + ON_MESSAGE(TurnOff) + ON_MESSAGE(MovieEndMsg) +END_MESSAGE_MAP() + void CChestOfDrawers::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CSGTStateRoom::save(file, indent); @@ -34,4 +40,41 @@ void CChestOfDrawers::load(SimpleFile *file) { CSGTStateRoom::load(file); } +bool CChestOfDrawers::TurnOn(CTurnOn *msg) { + if (_statics->_v6 == "Closed" && _statics->_v5 == "Open") { + _fieldE0 = false; + _statics->_v6 = "Open"; + _startFrame = 1; + _endFrame = 14; + playSound("b#11.wav"); + } + + return true; +} + +bool CChestOfDrawers::TurnOff(CTurnOff *msg) { + if (_statics->_v6 == "Open" && _statics->_v5 == "Closed") { + CVisibleMsg visibleMsg; + visibleMsg.execute("Drawer"); + _statics->_v6 = "Closed"; + _fieldE0 = true; + + _startFrame = 14; + _endFrame = 27; + playMovie(14, 27, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playSound("b#11.wav"); + } + + return true; +} + +bool CChestOfDrawers::MovieEndMsg(CMovieEndMsg *msg) { + if (_statics->_v6 == "Open") { + CVisibleMsg visibleMsg; + visibleMsg.execute("Drawer"); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sgt/chest_of_drawers.h b/engines/titanic/game/sgt/chest_of_drawers.h index 16a1bf8fea..5bf852902b 100644 --- a/engines/titanic/game/sgt/chest_of_drawers.h +++ b/engines/titanic/game/sgt/chest_of_drawers.h @@ -28,6 +28,10 @@ namespace Titanic { class CChestOfDrawers : public CSGTStateRoom { + DECLARE_MESSAGE_MAP; + bool TurnOn(CTurnOn *msg); + bool TurnOff(CTurnOff *msg); + bool MovieEndMsg(CMovieEndMsg *msg); public: CLASSDEF; |