aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/access/access.cpp5
-rw-r--r--engines/access/access.h3
-rw-r--r--engines/access/amazon/amazon_game.cpp2
-rw-r--r--engines/access/amazon/amazon_room.cpp7
-rw-r--r--engines/access/amazon/amazon_room.h6
-rw-r--r--engines/access/events.cpp33
-rw-r--r--engines/access/events.h13
-rw-r--r--engines/access/inventory.cpp9
-rw-r--r--engines/access/inventory.h4
-rw-r--r--engines/access/resources.cpp5
-rw-r--r--engines/access/resources.h2
-rw-r--r--engines/access/room.cpp141
-rw-r--r--engines/access/room.h19
-rw-r--r--engines/access/screen.cpp1
-rw-r--r--engines/access/screen.h1
-rw-r--r--engines/access/scripts.cpp18
16 files changed, 245 insertions, 24 deletions
diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index eaa65c7545..d6f19924b7 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -46,7 +46,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
_destIn = nullptr;
_current = nullptr;
_pCount = 0;
- _selectCommand = 0;
_normalMouse = true;
_mouseMode = 0;
_currentMan = 0;
@@ -312,4 +311,8 @@ void AccessEngine::copyBF2Vid() {
}
}
+void AccessEngine::doLoadSave() {
+ error("TODO: doLoadSave");
+}
+
} // End of namespace Access
diff --git a/engines/access/access.h b/engines/access/access.h
index 921d064a1d..81b1185922 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -130,7 +130,6 @@ public:
Common::Array<ExtraCell> _extraCells;
ImageEntryList _images;
int _pCount;
- int _selectCommand;
bool _normalMouse;
int _mouseMode;
@@ -224,6 +223,8 @@ public:
void copyBF1BF2();
void copyBF2Vid();
+
+ void doLoadSave();
};
} // End of namespace Access
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 0497dd8d4d..36d6d80e47 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -176,7 +176,7 @@ void AmazonEngine::setupGame() {
_player->_roomNumber = 4;
_player->_playerX = _player->_rawPlayer.x = TRAVEL_POS[_player->_roomNumber][0];
_player->_playerY = _player->_rawPlayer.y = TRAVEL_POS[_player->_roomNumber][1];
- _selectCommand = -1;
+ _room->_selectCommand = -1;
}
} // End of namespace Amazon
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index 5cb1dfe59c..cb6c8140ef 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -22,6 +22,7 @@
#include "common/scummsys.h"
#include "access/access.h"
+#include "access/resources.h"
#include "access/amazon/amazon_resources.h"
#include "access/amazon/amazon_room.h"
@@ -78,7 +79,7 @@ void AmazonRoom::reloadRoom1() {
_vm->_currentCharFlag = false;
}
- _vm->_selectCommand = -1;
+ _selectCommand = -1;
_vm->_normalMouse = 1;
_vm->_mouseMode = 0;
_vm->_boxSelect = true;
@@ -138,6 +139,10 @@ void AmazonRoom::roomMenu() {
delete spr;
}
+void AmazonRoom::mainAreaClick() {
+
+}
+
} // End of namespace Amazon
} // End of namespace Access
diff --git a/engines/access/amazon/amazon_room.h b/engines/access/amazon/amazon_room.h
index 546ea9698a..838b108fb5 100644
--- a/engines/access/amazon/amazon_room.h
+++ b/engines/access/amazon/amazon_room.h
@@ -38,14 +38,16 @@ private:
const byte *_icon;
void roomSet();
-
- void roomMenu();
protected:
virtual void loadRoom(int roomNumber);
virtual void reloadRoom();
virtual void reloadRoom1();
+
+ virtual void roomMenu();
+
+ virtual void mainAreaClick();
public:
AmazonRoom(AccessEngine *vm);
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index f373c8b829..8f02d41547 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -40,6 +40,10 @@ EventsManager::EventsManager(AccessEngine *vm): _vm(vm) {
_priorFrameTime = 0;
_leftButton = _rightButton = false;
_mouseMove = false;
+ _mouseCol = _mouseRow = 0;
+ _normalMouse = 0;
+ _mouseMode = 0;
+ _cursorExitFlag = false;
}
EventsManager::~EventsManager() {
@@ -103,10 +107,9 @@ bool EventsManager::isCursorVisible() {
return CursorMan.isVisible();
}
-void EventsManager::pollEvents() {
- checkForNextFrameCounter();
-
- _leftButton = false;
+void EventsManager::pollEvents(bool suppressFrames) {
+ if (!suppressFrames)
+ checkForNextFrameCounter();
Common::Event event;
while (g_system->getEventManager()->pollEvent(event)) {
@@ -122,6 +125,8 @@ void EventsManager::pollEvents() {
// Attach to the debugger
_vm->_debugger->attach();
_vm->_debugger->onFrame();
+ } else {
+
}
return;
case Common::EVENT_KEYUP:
@@ -174,5 +179,25 @@ void EventsManager::delay(int time) {
g_system->delayMillis(time);
}
+void EventsManager::zeroKeys() {
+ _keypresses.clear();
+}
+
+bool EventsManager::getKey(Common::KeyState &key) {
+ if (_keypresses.empty()) {
+ return false;
+ } else {
+ key = _keypresses.pop();
+ return true;
+ }
+}
+
+void EventsManager::debounceLeft() {
+ while (_leftButton && !_vm->shouldQuit()) {
+ pollEvents(true);
+ g_system->delayMillis(10);
+ }
+}
+
} // End of namespace Access
diff --git a/engines/access/events.h b/engines/access/events.h
index 7ee03ac21e..5ca08068f1 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -53,7 +53,12 @@ public:
CursorType _cursorId;
bool _leftButton, _rightButton;
Common::Point _mousePos;
+ int _mouseCol, _mouseRow;
bool _mouseMove;
+ int _normalMouse;
+ int _mouseMode;
+ bool _cursorExitFlag;
+ Common::FixedStack<Common::KeyState> _keypresses;
public:
/**
* Constructor
@@ -90,9 +95,15 @@ public:
*/
bool isCursorVisible();
- void pollEvents();
+ void pollEvents(bool suppressFrames = false);
+
+ void zeroKeys();
+
+ bool getKey(Common::KeyState &key);
void delay(int time);
+
+ void debounceLeft();
};
} // End of namespace Access
diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index 5d2957bd30..e784b873c9 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -58,4 +58,13 @@ void InventoryManager::setUseItem(int itemId) {
_vm->_useItem = itemId;
}
+void InventoryManager::refreshInventory() {
+ error("TODO: refreshInventory");
+}
+
+int InventoryManager::newDisplayInv() {
+ error("TODO: newDisplayInv");
+}
+
+
} // End of namespace Access
diff --git a/engines/access/inventory.h b/engines/access/inventory.h
index 1f229dd8ee..399c763483 100644
--- a/engines/access/inventory.h
+++ b/engines/access/inventory.h
@@ -47,6 +47,10 @@ public:
int useItem();
void setUseItem(int itemId);
+
+ void refreshInventory();
+
+ int newDisplayInv();
};
} // End of namespace Access
diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp
index 841ab70f04..40daf2b121 100644
--- a/engines/access/resources.cpp
+++ b/engines/access/resources.cpp
@@ -71,4 +71,9 @@ const int OVEROFFULY[] = { 1, 0, 0, 2, 1, 0, 0, 0, 0 };
const int OVEROFFDLX[] = { 1, 2, 1, 1, 2, 1, 0, 0, 0 };
const int OVEROFFDLY[] = { 0, 1, 0, 0, 1, 1, 0, 0, 0 };
+const int RMOUSE[10][2] = {
+ { 0, 35 }, { 0, 0 }, { 36, 70 }, { 71, 106 }, { 107, 141 },
+ { 142, 177 }, { 178, 212 }, { 213, 248 }, { 249, 283 }, { 284, 318 }
+};
+
} // End of namespace Access
diff --git a/engines/access/resources.h b/engines/access/resources.h
index 1b49b598ca..678cbc0614 100644
--- a/engines/access/resources.h
+++ b/engines/access/resources.h
@@ -54,6 +54,8 @@ extern const int OVEROFFULY[];
extern const int OVEROFFDLX[];
extern const int OVEROFFDLY[];
+extern const int RMOUSE[10][2];
+
} // End of namespace Access
#endif /* ACCESS_RESOURCES_H */
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index f42c8b092c..773a42b9d4 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -35,6 +35,8 @@ Room::Room(AccessEngine *vm) : Manager(vm) {
_playFieldWidth = _playFieldHeight = 0;
_matrixSize = 0;
_tile = nullptr;
+ _selectCommand = 0;
+ _conFlag = false;
}
Room::~Room() {
@@ -394,6 +396,138 @@ void Plotter::load(Common::SeekableReadStream *stream, int wallCount, int blockC
_blocks[i].bottom = stream->readSint16LE();
}
+void Room::doCommands() {
+ int commandId = 0;
+ Common::KeyState keyState;
+
+ if (_vm->_startup != -1)
+ return;
+
+ if (_vm->_inventory->_invChangeFlag)
+ _vm->_inventory->refreshInventory();
+
+ if (_vm->_screen->_screenChangeFlag) {
+ _vm->_screen->_screenChangeFlag = false;
+ _vm->_events->_cursorExitFlag = true;
+ executeCommand(4);
+ } else if (_vm->_events->_leftButton) {
+ if (_vm->_events->_mouseRow >= 22) {
+ // Mouse in user interface area
+ for (commandId = 0; commandId < 10; ++commandId) {
+ if (_vm->_events->_mousePos.x >= RMOUSE[commandId][0] &&
+ _vm->_events->_mousePos.x < RMOUSE[commandId][1])
+ break;
+ }
+ if (commandId < 10)
+ handleCommand(commandId);
+
+ } else {
+ // Mouse click in main game area
+ mainAreaClick();
+ }
+ } else if (_vm->_events->getKey(keyState)) {
+ if (keyState.ascii >= ';' && keyState.ascii <= 'D') {
+ handleCommand((int)keyState.ascii - ';');
+ }
+ }
+}
+
+void Room::handleCommand(int commandId) {
+ if (commandId == 1)
+ --commandId;
+
+ if (commandId == 9)
+ _vm->doLoadSave();
+ else if (commandId == _selectCommand) {
+ _vm->_events->debounceLeft();
+ commandOff();
+ } else {
+ _vm->_events->debounceLeft();
+ executeCommand(commandId);
+ }
+}
+
+void Room::executeCommand(int commandId) {
+ _selectCommand = commandId;
+
+ switch (commandId) {
+ case 0:
+ _vm->_events->_normalMouse = 4;
+ _vm->_events->_mouseMode = 0;
+ break;
+ case 2:
+ _vm->_events->_normalMouse = 5;
+ _vm->_events->_mouseMode = 0;
+ break;
+ case 3:
+ _vm->_events->_normalMouse = 6;
+ _vm->_events->_mouseMode = 0;
+ break;
+ case 4:
+ _vm->_events->_normalMouse = 1;
+ _vm->_events->setCursor(CURSOR_0);
+ if (_vm->_inventory->newDisplayInv() == 2) {
+ commandOff();
+ return;
+ } else {
+ warning("TODO: al = _useItem");
+ }
+ break;
+ case 5:
+ _vm->_events->_normalMouse = 7;
+ _vm->_events->_mouseMode = 0;
+ break;
+ case 6:
+ _vm->_events->_normalMouse = 8;
+ _vm->_events->_mouseMode = 0;
+ break;
+ case 7:
+ _vm->_events->_normalMouse = 1;
+ _vm->_scripts->_sequence = 5000;
+ _vm->_scripts->searchForSequence();
+ roomMenu();
+ _selectCommand = -1;
+ _vm->_events->_normalMouse = 1;
+ _vm->_events->_mouseMode = 0;
+
+ _conFlag = true;
+ while (_conFlag && !_vm->shouldQuit()) {
+ _conFlag = false;
+ _vm->_scripts->executeScript();
+ }
+ _vm->_boxSelect = true;
+ break;
+ case 8:
+ _vm->_events->_normalMouse = 9;
+ _vm->_events->_mouseMode = 0;
+ break;
+ default:
+ break;
+ }
+
+ roomMenu();
+ _vm->_screen->saveScreen();
+ _vm->_screen->setDisplayScan();
+
+ byte *iconData = _vm->_files->loadFile("ICONS.LZ");
+ SpriteResource *spr = new SpriteResource(_vm, iconData, _vm->_files->_filesize);
+ delete[] iconData;
+
+ // Draw the button as selected
+ _vm->_screen->plotImage(spr, _selectCommand + 2,
+ Common::Point(RMOUSE[_selectCommand][0], 176));
+
+ _vm->_screen->restoreScreen();
+ _vm->_boxSelect = true;
+}
+
+void Room::commandOff() {
+ _selectCommand = -1;
+ _vm->_events->_normalMouse = 1;
+ _vm->_events->_mouseMode = 4;
+ roomMenu();
+}
+
/*------------------------------------------------------------------------*/
RoomInfo::RoomInfo(const byte *data) {
@@ -428,20 +562,21 @@ RoomInfo::RoomInfo(const byte *data) {
_paletteFile._subfile = stream.readUint16LE();
if (_paletteFile._fileNum == -1) {
_startColor = _numColors = 0;
- } else {
+ }
+ else {
_startColor = stream.readUint16LE();
_numColors = stream.readUint16LE();
}
for (int16 v = (int16)stream.readUint16LE(); v != -1;
- v = (int16)stream.readUint16LE()) {
+ v = (int16)stream.readUint16LE()) {
uint16 v2 = stream.readUint16LE();
_vidTable.push_back(v | ((uint32)v2 << 16));
}
for (int16 fileNum = (int16)stream.readUint16LE(); fileNum != -1;
- fileNum = (int16)stream.readUint16LE()) {
+ fileNum = (int16)stream.readUint16LE()) {
SoundIdent fi;
fi._fileNum = fileNum;
fi._subfile = stream.readUint16LE();
diff --git a/engines/access/room.h b/engines/access/room.h
index 0569a925c9..00de53f0a7 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -63,6 +63,8 @@ private:
void roomLoop();
void loadPlayField(int fileNum, int subfile);
+
+ void commandOff();
protected:
void loadRoomData(const byte *roomData);
void setupRoom();
@@ -79,6 +81,15 @@ protected:
*/
void freeTileData();
+ /**
+ * Switch to a given command mode
+ */
+ void handleCommand(int commandId);
+
+ /**
+ * Inner handler for switching to a given command mode
+ */
+ void executeCommand(int commandId);
virtual void loadRoom(int roomNumber) = 0;
@@ -88,7 +99,11 @@ protected:
virtual void setIconPalette() {}
- virtual void doCommands() {}
+ virtual void doCommands();
+
+ virtual void roomMenu() = 0;
+
+ virtual void mainAreaClick() = 0;
public:
Plotter _plotter;
Common::Array<JetFrame> _jetFrame;
@@ -100,6 +115,8 @@ public:
int _playFieldHeight;
byte *_tile;
int _tileSize;
+ int _selectCommand;
+ bool _conFlag;
public:
Room(AccessEngine *vm);
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 9871fb1c3e..8e9b08234f 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -50,6 +50,7 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) {
_scrollCol = _scrollRow = 0;
_windowXAdd = _windowYAdd = 0;
_screenYOff = 0;
+ _screenChangeFlag = false;
_bufferBytesWide = _vWindowBytesWide = this->w;
_vWindowLinesTall = this->h;
diff --git a/engines/access/screen.h b/engines/access/screen.h
index 79c978f1d0..98e77b4cf4 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -78,6 +78,7 @@ public:
int _vWindowBytesWide;
int _bufferBytesWide;
int _vWindowLinesTall;
+ bool _screenChangeFlag;
public:
Screen(AccessEngine *vm);
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index ea93a04e9b..0cfce787a9 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -121,42 +121,42 @@ void Scripts::CMDOBJECT() { error("TODO CMDOBJECT"); }
void Scripts::CMDENDOBJECT() { error("TODO ENDOBJECT"); }
void Scripts::cmdJumpLook() {
- if (_vm->_selectCommand == 0)
+ if (_vm->_room->_selectCommand == 0)
cmdGoto();
else
_data->skip(2);
}
void Scripts::cmdJumpHelp() {
- if (_vm->_selectCommand == 8)
+ if (_vm->_room->_selectCommand == 8)
cmdGoto();
else
_data->skip(2);
}
void Scripts::cmdJumpGet() {
- if (_vm->_selectCommand == 3)
+ if (_vm->_room->_selectCommand == 3)
cmdGoto();
else
_data->skip(2);
}
void Scripts::cmdJumpMove() {
- if (_vm->_selectCommand == 2)
+ if (_vm->_room->_selectCommand == 2)
cmdGoto();
else
_data->skip(2);
}
void Scripts::cmdJumpUse() {
- if (_vm->_selectCommand == 4)
+ if (_vm->_room->_selectCommand == 4)
cmdGoto();
else
_data->skip(2);
}
void Scripts::cmdJumpTalk() {
- if (_vm->_selectCommand == 6)
+ if (_vm->_room->_selectCommand == 6)
cmdGoto();
else
_data->skip(2);
@@ -180,15 +180,15 @@ void Scripts::cmdAnim() {
void Scripts::cmdSetFlag() {
int flagNum = _data->readByte();
byte flagVal = _data->readByte();
-
assert(flagNum < 256);
+
_vm->_flags[flagNum] = flagVal;
}
void Scripts::cmdCheckFlag() {
int flagNum = _data->readUint16LE();
int flagVal = _data->readUint16LE();
- assert(flagNum < 100);
+ assert(flagNum < 256);
if (_vm->_flags[flagNum] == flagVal)
cmdGoto();
@@ -282,7 +282,7 @@ void Scripts::CMDSETTIMER() { error("TODO CMDSETTIMER"); }
void Scripts::CMDCHECKTIMER() { error("TODO CMDCHECKTIMER"); }
void Scripts::cmdSetTravel() {
- if (_vm->_selectCommand == 5)
+ if (_vm->_room->_selectCommand == 5)
cmdGoto();
else
_data->skip(2);