diff options
-rw-r--r-- | engines/supernova2/- | 221 | ||||
-rw-r--r-- | engines/supernova2/ms2_def.h | 16 | ||||
-rw-r--r-- | engines/supernova2/resman.cpp | 5 | ||||
-rw-r--r-- | engines/supernova2/rooms.cpp | 171 | ||||
-rw-r--r-- | engines/supernova2/rooms.h | 1 | ||||
-rw-r--r-- | engines/supernova2/sound.h | 5 | ||||
-rw-r--r-- | engines/supernova2/state.cpp | 24 | ||||
-rw-r--r-- | engines/supernova2/state.h | 1 |
8 files changed, 214 insertions, 230 deletions
diff --git a/engines/supernova2/- b/engines/supernova2/- deleted file mode 100644 index beda2e284d..0000000000 --- a/engines/supernova2/- +++ /dev/null @@ -1,221 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef SUPERNOVA2_STATE_H -#define SUPERNOVA2_STATE_H - -#include "common/events.h" -#include "common/rect.h" -#include "common/keyboard.h" -#include "supernova2/rooms.h" -#include "supernova2/sound.h" - -namespace Supernova2 { - -const int32 kMaxTimerValue = 0x7FFFFFFF; - -enum EventFunction { kNoFn, kSoberFn}; - -struct GameState { - int16 _money; - bool _addressKnown; - Room *_previousRoom; - bool _poleMagnet; - char _admission; - bool _tipsy; - bool _dark; - char _elevatorE; - char _elevatorNumber; - bool _toMuseum; - EventFunction _eventCallback; - uint32 _eventTime; -}; - -class Inventory { -public: - Inventory(Object *nullObject, int &inventoryScroll) - : _numObjects(0) - , _nullObject(nullObject) - , _inventoryScroll(inventoryScroll) { - for (int i = 0; i < kMaxCarry; ++i) - _inventory[i] = nullptr; - } - - void add(Object &obj); - void remove(Object &obj); - void clear(); - Object *get(int index) const; - Object *get(ObjectId id) const; - int getSize() const { return _numObjects; } - -private: - Object *_inventory[kMaxCarry]; - Object *_nullObject; - int &_inventoryScroll; - int _numObjects; -}; - -class GuiElement : public Common::Rect { -public: - GuiElement(); - - void setSize(int x1, int y1, int x2, int y2); - void setText(const char *text); - void setTextPosition(int x, int y); - void setColor(int bgColor, int textColor, int bgColorHighlighted, int textColorHightlighted); - void setHighlight(bool isHighlighted); - - const char *getText() const { - return _text; - } - int getBackgroundColor() const { - return _bgColor; - } - int getTextColor() const { - return _textColor; - } - const Common::Point &getTextPos() const { - return _textPosition; - } - bool isHighlighted() const { - return _isHighlighted; - } - -private: - Common::Point _textPosition; - char _text[128]; - int _bgColor; - int _textColor; - int _bgColorNormal; - int _bgColorHighlighted; - int _textColorNormal; - int _textColorHighlighted; - bool _isHighlighted; -}; - -class GameManager { -public: - GameManager(Supernova2Engine *vm); - ~GameManager(); - - void updateEvents(); - void processInput(Common::KeyState &state); - void processInput(); - void executeRoom(); - bool serialize(Common::WriteStream *out); - bool deserialize(Common::ReadStream *in, int version); - - static StringId guiCommands[]; - static StringId guiStatusCommands[]; - Supernova2Engine *_vm; - Common::KeyState _key; - Common::EventType _mouseClickType; - bool _mouseClicked; - bool _keyPressed; - int _mouseX; - int _mouseY; - int _mouseField; - Room *_currentRoom; - bool _newRoom; - Room *_rooms[NUMROOMS]; - Inventory _inventory; - GameState _state; - bool _processInput; - bool _guiEnabled; - bool _animationEnabled; - Action _inputVerb; - Object _nullObject; - Object *_currentInputObject; - Object *_inputObject[2]; - int32 _oldTime; - uint _timePaused; - bool _timerPaused; - int _restTime; - int32 _messageDuration; - int32 _animationTimer; - int _inventoryScroll; - int _exitList[25]; - GuiElement _guiCommandButton[10]; - GuiElement _guiInventory[8]; - GuiElement _guiInventoryArrow[2]; - // Dialog - int _currentSentence; - int _sentenceNumber[6]; - StringId _texts[6]; - byte _rows[6]; - byte _rowsStart[6]; - byte _dials[6]; - int _taxi_possibility; - - void takeObject(Object &obj); - void setObjectNull(Object *&obj); - bool isNullObject(Object *obj); - - void initState(); - void initRooms(); - void destroyRooms(); - void initGui(); - bool genericInteract(Action verb, Object &obj1, Object &obj2); - uint16 getKeyInput(bool blockForPrintChar = false); - void getInput(); - void wait(int ticks); - void waitOnInput(int ticks); - bool waitOnInput(int ticks, Common::KeyCode &keycode); - void showMenu(); - void edit(Common::String &input, int x, int y, uint length); - int invertSection(int section); - void drawMapExits(); - void drawStatus(); - void drawCommandBox(); - void drawInventory(); - void changeRoom(RoomId id); - void resetInputState(); - void handleInput(); - void handleTime(); - void pauseTimer(bool pause); - void setAnimationTimer(int ticks); - int dialog(int num, byte rowLength[6], StringId text[6], int number); - void sentence(int number, bool brightness); - void say(StringId textId); - void say(const char *text); - void reply(StringId textId, int aus1, int aus2); - void reply(const char *text, int aus1, int aus2); - void mousePosDialog(int x, int y); - void takeMoney(int amount); - void taxi(); - void leaveTaxi(); - void taxiUnknownDestination(); - void taxiPayment(int price, int destination); - void playerTakeOut(); - void sober(); - void playCD(); - void drawGUI(); - bool talk(int mod1, int mod2, int rest, MessagePosition pos, StringId id); - bool talkRest(int mod1, int mod2, int rest); - -private: - int _prevImgId; -}; - -} - -#endif // SUPERNOVA2_STATE_H diff --git a/engines/supernova2/ms2_def.h b/engines/supernova2/ms2_def.h index 6b37429fd4..70f83e8749 100644 --- a/engines/supernova2/ms2_def.h +++ b/engines/supernova2/ms2_def.h @@ -120,7 +120,7 @@ enum ObjectId { MAGNET,UNDER_BED,KEY,HATCH,CABINET,DISCMAN, SMALL_DOOR,BACK_MONEY,WALL,SUCTION_CUP,IMITATION,SP_KEYCARD,ALARM_CRACKER, ENCRYPTED_DOOR,ALARM_ANLAGE,MUS_STREET,BIG_DOOR,MUSIC_SYSTEM, - HANDLE,COUNTER,DOOR_SWITCH,SUIT,MANAGEMENT,RMANAGEMENT, + HANDLE,SWITCH,DOOR_SWITCH,SUIT,CABLE,RCABLE, MUSCARD,SKOPF, DISPLAY }; @@ -231,19 +231,19 @@ kStringElevator52, kStringElevator53, kStringElevator54, kStringElevator55, kStr kStringElevator57, kStringElevator58, kStringElevator59, kStringElevator60, kStringElevator61, kStringElevator62, kStringElevator63, kStringElevator64, kStringElevator65, kStringApartment1, kStringApartment2, kStringApartment3, kStringApartment4, kStringApartment5, kStringApartment6, -kStringApartment7, kStringApartment8, kString527, kString528, kString529, -kString530, kString531, kString532, kString533, kString534, -kString535, kString536, kString537, kString538, kString539, -kString540, kString541, kString542, kString543, kString544, -kString545, kString546, kStringFascinating, kStringTaxis, kStringTaxisDescription, +kStringApartment7, kStringApartment8, kStringShip0, kStringShip1, kStringShip2, +kStringShip3, kStringShip4, kStringShip5, kStringShip6, kStringShip7, +kStringShip8, kStringShip9, kStringShip10, kStringShip11, kStringShip12, +kStringShip13, kStringShip14, kStringShip15, kStringShip16, kStringShip17, +kStringShip18, kStringShip19, kStringFascinating, kStringTaxis, kStringTaxisDescription, kStringAxacussan, kStringParticipationCard, kStringAxacussian, kStringSign1Description, kStringSign2Description, kStringSign3Description, kStringSign4Description, kStringBell, kStringDisplay, kStringKeypad, kStringKeypadDescription, kStringChip, kStringChipDescription, kStringHatch, kStringHatchDescription, kStringMusicSystem, kStringMusicSystemDescription, kStringSpeakers, kStringSpeakersDescription, kStringPencils, kStringPencilsDescription, kStringMetalBlocks, kStringMetalBlocksDescription, kStringImage, kStringImageDescription, kStringCabinet, kStringCabinetDescription, kStringElevator, kStringUnderBed, kStringUnderBedDescription, -kStringKey, kStringKeyDescription, kString582, kString583, kString584, -kString585, kString586, kString587, kString588, kString589, +kStringKey, kStringKeyDescription, kStringSwitch, kStringHandle, kStringHatch2, +kStringSpaceSuit, kStringSpaceSuitDescription, kStringCable, kStringCableDescription1, kStringCableDescription2, kStringIntro6, kStringIntro7, kStringIntro8, kStringIntroTV1, kStringIntroTV2, kStringIntroTV3, kStringIntroTV4, kStringIntroTV5, kStringIntroTV6, kStringIntroTV7, kStringIntroTV8, kStringIntroTV9, kStringIntroTV10, kStringIntroTV11, kStringIntroTV12, diff --git a/engines/supernova2/resman.cpp b/engines/supernova2/resman.cpp index 479366966d..7074731a55 100644 --- a/engines/supernova2/resman.cpp +++ b/engines/supernova2/resman.cpp @@ -58,6 +58,11 @@ static const AudioInfo audioInfo[kAudioNumSamples] = { {55, 17020, 18230}, {53, 0, 5210}, {47, 17020, -1}, + {51, 9020, -1}, + {51, 0, 6010}, + {50, 0, -1}, + {51, 6010, 9020}, + {54, 0, -1} }; static const byte mouseNormal[64] = { diff --git a/engines/supernova2/rooms.cpp b/engines/supernova2/rooms.cpp index 0a440d9a42..b858619058 100644 --- a/engines/supernova2/rooms.cpp +++ b/engines/supernova2/rooms.cpp @@ -1535,6 +1535,8 @@ void Checkout::appearance() { _vm->removeMessage(); _gm->changeRoom(SHIP); _gm->_state._dark = true; + _vm->_screen->setViewportBrightness(1); + _vm->paletteBrightness(); _gm->drawGUI(); } @@ -1972,9 +1974,25 @@ Ship::Ship(Supernova2Engine *vm, GameManager *gm) { _vm = vm; _gm = gm; - _fileNumber = 6; + _fileNumber = 45; _id = SHIP; _shown[0] = kShownTrue; + _shown[1] = kShownFalse; + _shown[2] = kShownFalse; + _shown[3] = kShownFalse; + _shown[4] = kShownFalse; + _shown[5] = kShownFalse; + _shown[6] = kShownFalse; + _shown[7] = kShownFalse; + _shown[8] = kShownTrue; + + _objectState[0] = Object(_id, kStringSwitch, kStringDefaultDescription, SWITCH, PRESS | COMBINABLE, 0, 0, 0); + _objectState[1] = Object(_id, kStringHandle, kStringDefaultDescription, HANDLE, NULLTYPE, 255, 255, 0); + _objectState[2] = Object(_id, kStringHatch2, kStringDefaultDescription, NULLOBJECT, NULLTYPE, 255, 255, 0, SHIP, 19); + _objectState[3] = Object(_id, kStringSwitch, kStringDefaultDescription, DOOR_SWITCH, PRESS | COMBINABLE, 255, 255, 0); + _objectState[4] = Object(_id, kStringSpaceSuit, kStringSpaceSuitDescription, SUIT, TAKE, 255, 255, 1); + _objectState[5] = Object(_id, kStringCable, kStringCableDescription1, RCABLE, COMBINABLE, 255, 255, 0); + _objectState[6] = Object(_id, kStringCable, kStringCableDescription2, CABLE, TAKE | COMBINABLE, 255, 255, 8 + 128); } void Ship::onEntrance() { @@ -1985,9 +2003,160 @@ void Ship::animation() { } bool Ship::interact(Action verb, Object &obj1, Object &obj2) { + if (verb == ACTION_PRESS && obj1._id == SWITCH) { + if (_gm->_state._dark) { + _gm->_state._dark = false; + _vm->_screen->setViewportBrightness(255); + _objectState[1]._click = 1; + _objectState[2]._click = 2; + _objectState[3]._click = 3; + _objectState[5]._click = 4; + _objectState[6]._click = 5; + _objectState[2]._type = EXIT | OPENABLE | CLOSED; + _gm->drawMapExits(); + } + } else if (verb == ACTION_PRESS && obj1._id == DOOR_SWITCH && + !isSectionVisible(7)) { + _vm->renderImage(3); + _gm->wait(2); + _vm->renderImage(6); + _vm->playSound(kAudioShip1); + while (_vm->_sound->isPlaying()) + _gm->wait(1); + _vm->renderImage(6 + 128); + _vm->renderImage(7); + _objectState[3]._description = kStringShip1; + _objectState[2]._description = kStringShip2; + } else if (verb == ACTION_PULL && obj1._id == HANDLE) { + _vm->renderImage(2); + _vm->playSound(kAudioTaxiOpen); + obj1._click = 255; + _objectState[4]._click = 9; + } else if (verb == ACTION_TAKE && obj1._id == SUIT && !(obj1._type & CARRIED)) { + setSectionVisible(2, kShownFalse); + _gm->takeObject(obj1); + } else if (verb == ACTION_USE && obj1._id == SUIT) { + if (!(obj1._type & CARRIED)) { + setSectionVisible(2, kShownFalse); + _gm->takeObject(obj1); + } + if ((_shown[kMaxSection - 1] = !_shown[kMaxSection - 1])) + _vm->renderMessage(kStringShip3); + else + _vm->renderMessage(kStringShip4); + } else if (verb == ACTION_USE && Object::combine(obj1, obj2, CABLE, RCABLE)) { + _objectState[6]._description = kStringDefaultDescription; + if (_objectState[6]._click == 6) + _vm->renderImage(8 + 128); + if (_objectState[6]._type & CARRIED) + _gm->_inventory.remove(_objectState[6]); + if (isSectionVisible(11) || isSectionVisible(10)) + _vm->renderMessage(kStringShip5); + else if (isSectionVisible(9)) { + _vm->renderImage(9 + 128); + _vm->renderImage(11); + if (!_shown[kMaxSection - 1]) + kill(); + _objectState[6]._click = 8; + _gm->wait(2); + _vm->renderImage(4); + _vm->playSound(kAudioShip2); + _gm->wait(3); + _vm->renderImage(5); + _objectState[2]._type |= OPENED; + _objectState[2]._description = kStringDefaultDescription; + } else { + _vm->renderImage(10); + if (!_shown[kMaxSection - 1]) + kill(); + _objectState[6]._click = 7; + } + } else if (verb == ACTION_USE && Object::combine(obj1, obj2, CABLE, DOOR_SWITCH) && isSectionVisible(7)) { + _objectState[6]._description = kStringDefaultDescription; + if (_objectState[6]._click == 5) + _vm->renderImage(8 + 128); + if (_objectState[6]._type & CARRIED) + _gm->_inventory.remove(_objectState[6]); + if (isSectionVisible(11) || isSectionVisible(9)) + _vm->renderMessage(kStringShip5); + else if (isSectionVisible(10)) { + _vm->renderImage(10 + 128); + _vm->renderImage(11); + if (!_shown[kMaxSection - 1]) + kill(); + _objectState[6]._click = 8; + _gm->wait(2); + _vm->renderImage(4); + _vm->playSound(kAudioShip2); + _gm->wait(3); + _vm->renderImage(5); + _objectState[2]._type |= OPENED; + _objectState[2]._description = kStringDefaultDescription; + } else { + _vm->renderImage(9); + _objectState[6]._click = 6; + } + } else if (verb == ACTION_TAKE && obj1._id == CABLE && obj1._type & CARRIED) { + if (isSectionVisible(8)) { + obj1._description = kStringDefaultDescription; + _gm->takeObject(obj1); + } else + _vm->renderMessage(kStringShip6); + } else if (verb == ACTION_WALK && obj1._type == (EXIT | OPENABLE | CLOSED | OPENED)) { + _vm->setCurrentImage(46); + _vm->renderImage(0); + _gm->wait(16); + _vm->renderMessage(kStringShip7, kMessageRight); + _gm->waitOnInput(_gm->_messageDuration); + _vm->removeMessage(); + _gm->reply(kStringShip8, 1, 1 + 128); + _vm->renderMessage(kStringShip9, kMessageRight); + _gm->waitOnInput(_gm->_messageDuration); + _vm->removeMessage(); + _gm->reply(kStringShip10, 1, 1 + 128); + _gm->reply(kStringShip11, 1, 1 + 128); + _gm->reply(kStringShip12, 1, 1 + 128); + _gm->reply(kStringShip13, 1, 1 + 128); + _vm->renderMessage(kStringShip14, kMessageRight); + _gm->waitOnInput(_gm->_messageDuration); + _vm->removeMessage(); + _gm->reply(kStringShip15, 1, 1 + 128); + _vm->renderMessage(kStringShip16, kMessageRight); + _gm->waitOnInput(_gm->_messageDuration); + _vm->removeMessage(); + _gm->reply(kStringAha, 1, 1 + 128); + _gm->reply(kStringShip17, 1, 1 + 128); + _vm->renderMessage(kStringShip18, kMessageRight); + _gm->waitOnInput(_gm->_messageDuration); + _vm->removeMessage(); + _gm->reply(kStringShip19, 1, 1 + 128); + _gm->wait(16); + CursorMan.showMouse(false); + _vm->renderImage(2); + for (int i = 3; i < 12; i++) { + _vm->renderImage(i); + if (i == 9) + _vm->playSound(kAudioShip3); + _gm->wait(2); + _vm->renderImage(i + 128); + } + _vm->renderImage(12); + _gm->wait(18); + // TODO some palette stuff + _vm->renderImage(13); + _vm->playSound(kMusicMadMonkeys); + } else + return false; return true; } +void Ship::kill() { + _vm->playSound(kAudioShipDeath); + while (_vm->_sound->isPlaying()) + _gm->wait(1); + _gm->dead(kStringShip0); +} + Pyramid::Pyramid(Supernova2Engine *vm, GameManager *gm) { _vm = vm; _gm = gm; diff --git a/engines/supernova2/rooms.h b/engines/supernova2/rooms.h index 4145f8028a..aed69012a5 100644 --- a/engines/supernova2/rooms.h +++ b/engines/supernova2/rooms.h @@ -221,6 +221,7 @@ public: virtual bool interact(Action verb, Object &obj1, Object &obj2); private: + void kill(); }; class Pyramid : public Room { diff --git a/engines/supernova2/sound.h b/engines/supernova2/sound.h index 692e47bc6f..d54bac9cf0 100644 --- a/engines/supernova2/sound.h +++ b/engines/supernova2/sound.h @@ -44,6 +44,11 @@ enum AudioId { kAudioAppearance3, kAudioElevatorBell, kAudioElevator1, + kAudioShip1, + kAudioShip2, + kAudioShip3, + kAudioShipDeath, + kAudioDeath, kAudioNumSamples }; diff --git a/engines/supernova2/state.cpp b/engines/supernova2/state.cpp index 019ad19011..cbd3fdcd9e 100644 --- a/engines/supernova2/state.cpp +++ b/engines/supernova2/state.cpp @@ -1171,6 +1171,30 @@ void GameManager::pauseTimer(bool pause) { } } +void GameManager::dead(StringId messageId) { + _vm->paletteFadeOut(); + _guiEnabled = false; + _vm->setCurrentImage(43); + _vm->renderImage(0); + _vm->renderMessage(messageId); + _vm->_sound->play(kAudioDeath); + _vm->paletteFadeIn(); + getInput(); + _vm->paletteFadeOut(); + _vm->removeMessage(); + + destroyRooms(); + initRooms(); + initState(); + initGui(); + _inventory.clear(); + changeRoom(AIRPORT); + g_system->fillScreen(kColorBlack); + _vm->paletteFadeIn(); + + _guiEnabled = true; +} + int GameManager::invertSection(int section) { if (section < 128) section += 128; diff --git a/engines/supernova2/state.h b/engines/supernova2/state.h index b356dd9c83..2834851367 100644 --- a/engines/supernova2/state.h +++ b/engines/supernova2/state.h @@ -196,6 +196,7 @@ public: void handleTime(); void pauseTimer(bool pause); void setAnimationTimer(int ticks); + void dead(StringId messageId); int dialog(int num, byte rowLength[6], StringId text[6], int number); void sentence(int number, bool brightness); void say(StringId textId); |