ACCESS: Implementing doCommand
This commit is contained in:
parent
8648480258
commit
b3ab8a42a6
16 changed files with 245 additions and 24 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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,11 +107,10 @@ bool EventsManager::isCursorVisible() {
|
|||
return CursorMan.isVisible();
|
||||
}
|
||||
|
||||
void EventsManager::pollEvents() {
|
||||
void EventsManager::pollEvents(bool suppressFrames) {
|
||||
if (!suppressFrames)
|
||||
checkForNextFrameCounter();
|
||||
|
||||
_leftButton = false;
|
||||
|
||||
Common::Event event;
|
||||
while (g_system->getEventManager()->pollEvent(event)) {
|
||||
// Handle keypress
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -47,6 +47,10 @@ public:
|
|||
|
||||
int useItem();
|
||||
void setUseItem(int itemId);
|
||||
|
||||
void refreshInventory();
|
||||
|
||||
int newDisplayInv();
|
||||
};
|
||||
|
||||
} // End of namespace Access
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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,7 +562,8 @@ RoomInfo::RoomInfo(const byte *data) {
|
|||
_paletteFile._subfile = stream.readUint16LE();
|
||||
if (_paletteFile._fileNum == -1) {
|
||||
_startColor = _numColors = 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
_startColor = stream.readUint16LE();
|
||||
_numColors = stream.readUint16LE();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -78,6 +78,7 @@ public:
|
|||
int _vWindowBytesWide;
|
||||
int _bufferBytesWide;
|
||||
int _vWindowLinesTall;
|
||||
bool _screenChangeFlag;
|
||||
public:
|
||||
Screen(AccessEngine *vm);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue