2012-09-08 08:45:22 +00:00
|
|
|
/* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common/system.h"
|
2012-09-15 03:23:46 +00:00
|
|
|
#include "common/textconsole.h"
|
2012-11-09 11:11:38 +00:00
|
|
|
#include "graphics/cursorman.h"
|
2012-09-08 08:45:22 +00:00
|
|
|
#include "hopkins/events.h"
|
2012-09-19 11:34:23 +00:00
|
|
|
#include "hopkins/files.h"
|
|
|
|
#include "hopkins/globals.h"
|
|
|
|
#include "hopkins/hopkins.h"
|
|
|
|
#include "hopkins/sound.h"
|
2012-09-08 08:45:22 +00:00
|
|
|
|
|
|
|
namespace Hopkins {
|
|
|
|
|
2012-09-15 00:27:15 +00:00
|
|
|
EventsManager::EventsManager() {
|
2012-12-11 00:53:50 +00:00
|
|
|
_mouseFl = false;
|
|
|
|
_mouseLinuxFl = false;
|
|
|
|
_mouseSizeX = _mouseSizeY = 0;
|
|
|
|
_mouseOffset.x = _mouseOffset.y = 0;
|
|
|
|
_startPos.x = _startPos.y = 0;
|
|
|
|
_breakoutFl = false;
|
2012-12-11 07:31:07 +00:00
|
|
|
_mouseSpriteId = 0;
|
|
|
|
_curMouseButton = 0;
|
|
|
|
_mouseButton = 0;
|
2012-12-11 00:53:50 +00:00
|
|
|
_mouseCursor = NULL;
|
2012-10-27 09:19:21 +00:00
|
|
|
_gameCounter = 0;
|
2012-12-11 07:31:07 +00:00
|
|
|
_rateCounter = 0;
|
2012-12-11 00:53:50 +00:00
|
|
|
_escKeyFl = false;
|
|
|
|
_gameKey = KEY_NONE;
|
2012-12-11 07:31:07 +00:00
|
|
|
_mouseCursorId = 0;
|
2012-12-11 00:53:50 +00:00
|
|
|
_oldIconId = 0;
|
|
|
|
_objectBuf = NULL;
|
2012-10-13 07:27:14 +00:00
|
|
|
|
2012-12-11 00:53:50 +00:00
|
|
|
Common::fill(&_keyState[0], &_keyState[256], false);
|
2012-10-13 07:27:14 +00:00
|
|
|
_priorCounterTime = 0;
|
|
|
|
_priorFrameTime = 0;
|
2012-09-19 11:34:23 +00:00
|
|
|
}
|
|
|
|
|
2012-11-01 11:35:33 +00:00
|
|
|
EventsManager::~EventsManager() {
|
2012-12-12 07:05:04 +00:00
|
|
|
_vm->_globals.freeMemory(_objectBuf);
|
|
|
|
_vm->_globals.freeMemory(_mouseCursor);
|
2012-11-01 11:35:33 +00:00
|
|
|
}
|
|
|
|
|
2012-09-19 11:34:23 +00:00
|
|
|
void EventsManager::setParent(HopkinsEngine *vm) {
|
|
|
|
_vm = vm;
|
2012-09-15 00:27:15 +00:00
|
|
|
}
|
|
|
|
|
2012-10-20 16:59:06 +00:00
|
|
|
// Mouse On
|
2012-12-11 00:53:50 +00:00
|
|
|
void EventsManager::setMouseOn() {
|
|
|
|
_mouseFl = true;
|
2012-09-08 08:45:22 +00:00
|
|
|
|
2012-12-11 00:53:50 +00:00
|
|
|
if (_mouseLinuxFl) {
|
|
|
|
_mouseSizeX = 52;
|
|
|
|
_mouseSizeY = 32;
|
2012-09-08 08:45:22 +00:00
|
|
|
} else {
|
2012-12-11 00:53:50 +00:00
|
|
|
_mouseSizeX = 34;
|
|
|
|
_mouseSizeY = 20;
|
2012-09-08 08:45:22 +00:00
|
|
|
}
|
|
|
|
|
2012-12-11 00:53:50 +00:00
|
|
|
_mouseOffset.x = 0;
|
|
|
|
_mouseOffset.y = 0;
|
2012-09-08 08:45:22 +00:00
|
|
|
|
2012-12-11 00:53:50 +00:00
|
|
|
if (!_breakoutFl)
|
|
|
|
setMouseXY(300, 200);
|
2012-09-08 08:45:22 +00:00
|
|
|
else
|
2012-12-11 00:53:50 +00:00
|
|
|
setMouseXY(150, 100);
|
2012-09-08 08:45:22 +00:00
|
|
|
}
|
|
|
|
|
2012-12-11 00:53:50 +00:00
|
|
|
/**
|
|
|
|
* Set Mouse position
|
|
|
|
*/
|
|
|
|
void EventsManager::setMouseXY(int xp, int yp) {
|
2012-09-08 08:45:22 +00:00
|
|
|
g_system->warpMouse(xp, yp);
|
|
|
|
}
|
|
|
|
|
2012-12-11 00:53:50 +00:00
|
|
|
/**
|
|
|
|
* Get Mouse X
|
|
|
|
*/
|
|
|
|
int EventsManager::getMouseX() {
|
|
|
|
_mousePos.x = _startPos.x + g_system->getEventManager()->getMousePos().x;
|
|
|
|
_mousePos.y = g_system->getEventManager()->getMousePos().y;
|
2012-09-15 03:23:46 +00:00
|
|
|
|
2012-12-11 00:53:50 +00:00
|
|
|
return _mousePos.x + _mouseOffset.x;
|
2012-09-15 03:23:46 +00:00
|
|
|
}
|
|
|
|
|
2012-12-11 00:53:50 +00:00
|
|
|
/**
|
|
|
|
* Get Mouse Y
|
|
|
|
*/
|
|
|
|
int EventsManager::getMouseY() {
|
|
|
|
_mousePos.x = _startPos.x + g_system->getEventManager()->getMousePos().x;
|
|
|
|
_mousePos.y = g_system->getEventManager()->getMousePos().y;
|
2012-09-15 03:23:46 +00:00
|
|
|
|
2012-12-11 00:53:50 +00:00
|
|
|
return _mousePos.y + _mouseOffset.y;
|
2012-09-15 03:23:46 +00:00
|
|
|
}
|
|
|
|
|
2012-12-11 00:53:50 +00:00
|
|
|
/**
|
|
|
|
* Get Mouse Button
|
|
|
|
*/
|
|
|
|
int EventsManager::getMouseButton() {
|
2012-12-11 07:31:07 +00:00
|
|
|
refreshEvents();
|
|
|
|
return _curMouseButton;
|
2012-09-15 00:27:15 +00:00
|
|
|
}
|
|
|
|
|
2012-12-11 00:53:50 +00:00
|
|
|
/**
|
|
|
|
* Mouse Off
|
|
|
|
*/
|
|
|
|
void EventsManager::mouseOff() {
|
|
|
|
_mouseFl = false;
|
2012-11-09 11:11:38 +00:00
|
|
|
CursorMan.showMouse(false);
|
2012-09-17 06:53:21 +00:00
|
|
|
}
|
|
|
|
|
2012-12-11 00:53:50 +00:00
|
|
|
/**
|
|
|
|
* Mouse On
|
|
|
|
*/
|
|
|
|
void EventsManager::mouseOn() {
|
|
|
|
setMouseOn();
|
|
|
|
_mouseFl = true;
|
2012-11-09 11:11:38 +00:00
|
|
|
CursorMan.showMouse(true);
|
2012-09-17 06:53:21 +00:00
|
|
|
}
|
|
|
|
|
2012-12-11 00:53:50 +00:00
|
|
|
/**
|
|
|
|
* Change Mouse Cursor
|
|
|
|
*/
|
|
|
|
void EventsManager::changeMouseCursor(int id) {
|
2012-09-19 11:34:23 +00:00
|
|
|
int cursorId = id;
|
|
|
|
|
2012-12-11 07:31:07 +00:00
|
|
|
if (_mouseCursorId != 23) {
|
|
|
|
if (id == 4 && _mouseCursorId == 4 && _vm->_globals.NOMARCHE)
|
2012-12-12 22:16:07 +00:00
|
|
|
cursorId = 0;
|
|
|
|
if (cursorId == 25)
|
|
|
|
cursorId = 5;
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-12-12 22:16:07 +00:00
|
|
|
if (_oldIconId != cursorId || !cursorId) {
|
|
|
|
_oldIconId = cursorId;
|
|
|
|
_mouseSpriteId = cursorId;
|
2012-09-21 23:55:40 +00:00
|
|
|
|
2012-11-01 11:35:33 +00:00
|
|
|
updateCursor();
|
2012-09-19 11:34:23 +00:00
|
|
|
}
|
|
|
|
}
|
2012-09-15 00:27:15 +00:00
|
|
|
}
|
|
|
|
|
2012-12-11 07:31:07 +00:00
|
|
|
/**
|
|
|
|
* Check Events
|
|
|
|
*/
|
|
|
|
void EventsManager::refreshEvents() {
|
2012-11-12 09:09:29 +00:00
|
|
|
_vm->_soundManager.checkSounds();
|
2012-11-11 07:58:45 +00:00
|
|
|
|
2012-09-15 00:27:15 +00:00
|
|
|
pollEvents();
|
2012-09-08 13:43:35 +00:00
|
|
|
}
|
|
|
|
|
2012-09-15 01:45:36 +00:00
|
|
|
void EventsManager::checkForNextFrameCounter() {
|
2012-10-13 07:27:14 +00:00
|
|
|
// Check for whether to increment the game counter
|
2012-09-15 00:27:15 +00:00
|
|
|
uint32 milli = g_system->getMillis();
|
2012-10-13 07:27:14 +00:00
|
|
|
while ((milli - _priorCounterTime) >= 10) {
|
|
|
|
_priorCounterTime += 10;
|
2012-12-11 07:31:07 +00:00
|
|
|
_rateCounter += 3;
|
2012-10-13 07:27:14 +00:00
|
|
|
}
|
2012-09-15 01:45:36 +00:00
|
|
|
|
2012-10-13 07:27:14 +00:00
|
|
|
// Check for next game frame
|
|
|
|
if ((milli - _priorFrameTime) >= GAME_FRAME_TIME) {
|
2012-10-28 03:51:17 +00:00
|
|
|
++_gameCounter;
|
2012-10-13 07:27:14 +00:00
|
|
|
_priorFrameTime = milli;
|
2012-09-15 01:45:36 +00:00
|
|
|
g_system->updateScreen();
|
2012-10-14 02:43:29 +00:00
|
|
|
|
|
|
|
// Signal the ScummVM debugger
|
|
|
|
_vm->_debugger.onFrame();
|
2012-09-15 00:27:15 +00:00
|
|
|
}
|
2012-09-15 01:45:36 +00:00
|
|
|
}
|
|
|
|
|
2012-09-30 11:33:00 +00:00
|
|
|
void EventsManager::delay(int totalMilli) {
|
|
|
|
uint32 delayEnd = g_system->getMillis() + totalMilli;
|
2012-09-15 00:27:15 +00:00
|
|
|
|
2012-09-15 01:45:36 +00:00
|
|
|
while (!g_system->getEventManager()->shouldQuit() && g_system->getMillis() < delayEnd) {
|
|
|
|
g_system->delayMillis(10);
|
2012-12-14 00:49:22 +00:00
|
|
|
}
|
2012-09-15 01:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EventsManager::pollEvents() {
|
2012-09-15 11:42:20 +00:00
|
|
|
checkForNextFrameCounter();
|
|
|
|
|
2012-09-15 00:27:15 +00:00
|
|
|
Common::Event event;
|
|
|
|
while (g_system->getEventManager()->pollEvent(event)) {
|
|
|
|
// Handle keypress
|
|
|
|
switch (event.type) {
|
|
|
|
case Common::EVENT_QUIT:
|
|
|
|
case Common::EVENT_RTL:
|
|
|
|
return;
|
|
|
|
|
|
|
|
case Common::EVENT_KEYDOWN:
|
2012-12-11 00:53:50 +00:00
|
|
|
_keyState[(byte)toupper(event.kbd.ascii)] = true;
|
2012-10-24 08:55:43 +00:00
|
|
|
handleKey(event);
|
2012-09-15 00:27:15 +00:00
|
|
|
return;
|
2012-11-18 08:31:43 +00:00
|
|
|
case Common::EVENT_KEYUP:
|
2012-12-11 00:53:50 +00:00
|
|
|
_keyState[(byte)toupper(event.kbd.ascii)] = false;
|
2012-11-18 08:31:43 +00:00
|
|
|
return;
|
2012-09-15 00:27:15 +00:00
|
|
|
case Common::EVENT_LBUTTONDOWN:
|
2012-12-11 07:31:07 +00:00
|
|
|
_mouseButton = 1;
|
2012-11-21 22:55:16 +00:00
|
|
|
return;
|
2012-09-15 00:27:15 +00:00
|
|
|
case Common::EVENT_RBUTTONDOWN:
|
2012-12-11 07:31:07 +00:00
|
|
|
_mouseButton = 2;
|
2012-11-21 22:55:16 +00:00
|
|
|
return;
|
2012-09-22 10:45:08 +00:00
|
|
|
case Common::EVENT_LBUTTONUP:
|
2012-09-15 00:27:15 +00:00
|
|
|
case Common::EVENT_RBUTTONUP:
|
2012-12-11 07:31:07 +00:00
|
|
|
_mouseButton = 0;
|
2012-09-15 00:27:15 +00:00
|
|
|
return;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-11-21 22:55:16 +00:00
|
|
|
|
|
|
|
for (char chr = 'A'; chr <= 'Z'; chr++)
|
2012-12-11 00:53:50 +00:00
|
|
|
_keyState[(byte)chr] = false;
|
2012-11-21 22:55:16 +00:00
|
|
|
|
|
|
|
for (char chr = '0'; chr <= '9'; chr++)
|
2012-12-11 00:53:50 +00:00
|
|
|
_keyState[(byte)chr] = false;
|
2012-09-08 13:43:35 +00:00
|
|
|
}
|
|
|
|
|
2012-10-24 08:55:43 +00:00
|
|
|
void EventsManager::handleKey(Common::Event &event) {
|
2012-12-11 00:53:50 +00:00
|
|
|
_escKeyFl = (event.kbd.keycode == Common::KEYCODE_ESCAPE);
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-10-28 03:26:07 +00:00
|
|
|
if (event.kbd.keycode == Common::KEYCODE_i || event.kbd.keycode == Common::KEYCODE_TAB)
|
2012-12-11 00:53:50 +00:00
|
|
|
_gameKey = KEY_INVENTORY;
|
2012-10-28 03:26:07 +00:00
|
|
|
else if (event.kbd.keycode == Common::KEYCODE_F5)
|
2012-12-11 00:53:50 +00:00
|
|
|
_gameKey = KEY_SAVE;
|
2012-10-28 03:26:07 +00:00
|
|
|
else if (event.kbd.keycode == Common::KEYCODE_F7)
|
2012-12-11 00:53:50 +00:00
|
|
|
_gameKey = KEY_LOAD;
|
2012-10-28 03:26:07 +00:00
|
|
|
else if (event.kbd.keycode == Common::KEYCODE_F1 || event.kbd.keycode == Common::KEYCODE_o)
|
2012-12-11 00:53:50 +00:00
|
|
|
_gameKey = KEY_OPTIONS;
|
2012-10-24 08:55:43 +00:00
|
|
|
|
|
|
|
// Check for debugger
|
|
|
|
if ((event.kbd.keycode == Common::KEYCODE_d) && (event.kbd.flags & Common::KBD_CTRL)) {
|
|
|
|
// Attach to the debugger
|
|
|
|
_vm->_debugger.attach();
|
|
|
|
_vm->_debugger.onFrame();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-12-11 07:31:07 +00:00
|
|
|
/**
|
|
|
|
* Waits for a keypress, ignoring mouse events
|
|
|
|
* @return Keypress, or -1 if game quit was requested
|
|
|
|
*/
|
|
|
|
int EventsManager::waitKeyPress() {
|
2012-11-18 08:31:43 +00:00
|
|
|
char foundChar = '\0';
|
|
|
|
|
|
|
|
while (!foundChar) {
|
|
|
|
if (_vm->shouldQuit())
|
|
|
|
return -1;
|
2012-11-17 09:49:07 +00:00
|
|
|
|
2012-11-18 08:31:43 +00:00
|
|
|
for (char ch = 'A'; ch <= 'Z'; ++ch) {
|
2012-12-11 00:53:50 +00:00
|
|
|
if (_keyState[(byte)ch]) {
|
2012-11-18 08:31:43 +00:00
|
|
|
foundChar = ch;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-11-17 09:49:07 +00:00
|
|
|
|
2012-11-18 08:31:43 +00:00
|
|
|
for (char ch = '0'; ch <= '9'; ++ch) {
|
2012-12-11 00:53:50 +00:00
|
|
|
if (_keyState[(byte)ch]) {
|
2012-11-18 08:31:43 +00:00
|
|
|
foundChar = ch;
|
|
|
|
break;
|
|
|
|
}
|
2012-11-17 09:49:07 +00:00
|
|
|
}
|
|
|
|
|
2012-12-11 00:53:50 +00:00
|
|
|
if (_keyState[(byte)'.'])
|
2012-11-18 08:31:43 +00:00
|
|
|
foundChar = '.';
|
2012-12-11 00:53:50 +00:00
|
|
|
else if (_keyState[8])
|
2012-11-21 22:55:16 +00:00
|
|
|
// BACKSPACE
|
2012-11-18 08:31:43 +00:00
|
|
|
foundChar = 8;
|
2012-12-11 00:53:50 +00:00
|
|
|
else if (_keyState[13])
|
2012-11-21 22:55:16 +00:00
|
|
|
// ENTER
|
2012-11-18 08:31:43 +00:00
|
|
|
foundChar = 13;
|
2012-12-11 00:53:50 +00:00
|
|
|
else if (_keyState[(byte)' '])
|
2012-11-18 08:31:43 +00:00
|
|
|
foundChar = ' ';
|
|
|
|
|
|
|
|
VBL();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Wait for keypress release
|
2012-12-11 00:53:50 +00:00
|
|
|
while (_keyState[(byte)foundChar] && !_vm->shouldQuit()) {
|
2012-11-18 08:31:43 +00:00
|
|
|
VBL();
|
2012-11-17 09:49:07 +00:00
|
|
|
g_system->delayMillis(10);
|
|
|
|
}
|
|
|
|
|
2012-11-18 08:31:43 +00:00
|
|
|
// Return character
|
|
|
|
return foundChar;
|
2012-11-17 09:49:07 +00:00
|
|
|
}
|
|
|
|
|
2012-09-23 00:59:52 +00:00
|
|
|
void EventsManager::VBL() {
|
2012-10-22 12:18:10 +00:00
|
|
|
int v1;
|
2012-12-14 00:49:22 +00:00
|
|
|
int v2;
|
|
|
|
int v3;
|
2012-09-23 00:59:52 +00:00
|
|
|
signed int v11 = 0;
|
|
|
|
signed int v12 = 0;
|
2012-12-14 00:49:22 +00:00
|
|
|
int v13 = 0;
|
|
|
|
unsigned int v14 = 0;
|
|
|
|
int v15 = 0;
|
2012-10-13 07:27:14 +00:00
|
|
|
int yp = 0;
|
|
|
|
|
|
|
|
if (_vm->_graphicsManager.REDRAW) {
|
2012-12-19 01:15:32 +00:00
|
|
|
_vm->_graphicsManager.lockScreen();
|
2012-12-11 00:53:50 +00:00
|
|
|
if (_breakoutFl) {
|
2012-12-19 01:15:32 +00:00
|
|
|
_vm->_graphicsManager.CopyAsm(_vm->_graphicsManager._vesaBuffer);
|
2012-10-13 07:27:14 +00:00
|
|
|
_vm->_graphicsManager.REDRAW = 0;
|
2012-09-23 00:59:52 +00:00
|
|
|
} else {
|
|
|
|
if (_vm->_globals.iRegul == 3)
|
2012-12-21 07:12:02 +00:00
|
|
|
_vm->_graphicsManager.m_scroll(_vm->_graphicsManager._vesaBuffer, _vm->_graphicsManager.ofscroll, 50, 640, 340, 0, 50);
|
2012-09-23 00:59:52 +00:00
|
|
|
else
|
2012-12-21 07:12:02 +00:00
|
|
|
_vm->_graphicsManager.m_scroll(_vm->_graphicsManager._vesaBuffer, _vm->_graphicsManager.ofscroll, 20, 640, 440, 0, 20);
|
2012-10-13 07:27:14 +00:00
|
|
|
--_vm->_graphicsManager.REDRAW;
|
2012-09-23 00:59:52 +00:00
|
|
|
}
|
2012-12-19 01:15:32 +00:00
|
|
|
_vm->_graphicsManager.unlockScreen();
|
2012-09-23 00:59:52 +00:00
|
|
|
}
|
2012-12-11 00:53:50 +00:00
|
|
|
if (_mouseFl == true) {
|
2012-09-23 00:59:52 +00:00
|
|
|
v1 = 20;
|
2012-12-11 00:53:50 +00:00
|
|
|
if (!_mouseLinuxFl)
|
2012-09-23 00:59:52 +00:00
|
|
|
v1 = 10;
|
|
|
|
v2 = 20;
|
2012-12-11 00:53:50 +00:00
|
|
|
if (!_mouseLinuxFl)
|
2012-09-23 00:59:52 +00:00
|
|
|
v2 = 15;
|
2012-12-11 00:53:50 +00:00
|
|
|
v15 = _mousePos.x - v1;
|
|
|
|
yp = _mousePos.y;
|
|
|
|
v14 = _mouseSizeX;
|
|
|
|
v13 = _mouseSizeY;
|
2012-12-11 07:31:07 +00:00
|
|
|
if (_mouseCursorId == 23) {
|
2012-12-19 07:00:22 +00:00
|
|
|
v14 = _vm->_globals._objectWidth;
|
|
|
|
v13 = _vm->_globals._objectHeight;
|
2012-09-23 00:59:52 +00:00
|
|
|
goto LABEL_35;
|
|
|
|
}
|
2012-12-11 00:53:50 +00:00
|
|
|
if (_breakoutFl) {
|
2012-10-13 07:27:14 +00:00
|
|
|
if (v15 < _vm->_graphicsManager.min_x)
|
|
|
|
v15 = _vm->_graphicsManager.min_x;
|
2012-12-11 00:53:50 +00:00
|
|
|
if (_mousePos.y < _vm->_graphicsManager.min_y)
|
2012-10-13 07:27:14 +00:00
|
|
|
yp = _vm->_graphicsManager.min_y;
|
2012-12-11 00:53:50 +00:00
|
|
|
if (_mouseSizeX + v15 >= _vm->_graphicsManager.max_x)
|
|
|
|
v14 = _mouseSizeX - (_mouseSizeX + v15 - _vm->_graphicsManager.max_x);
|
|
|
|
if (yp + _mouseSizeY < _vm->_graphicsManager.max_y)
|
2012-09-23 00:59:52 +00:00
|
|
|
goto LABEL_34;
|
2012-12-11 00:53:50 +00:00
|
|
|
v3 = yp + _mouseSizeY - _vm->_graphicsManager.max_y;
|
2012-09-23 00:59:52 +00:00
|
|
|
} else {
|
2012-10-13 07:27:14 +00:00
|
|
|
if (v15 < _vm->_graphicsManager.min_x)
|
|
|
|
v15 = _vm->_graphicsManager.min_x - v1;
|
2012-10-22 12:18:10 +00:00
|
|
|
v2 = (int16)v2;
|
2012-12-11 00:53:50 +00:00
|
|
|
if (_mousePos.y < _vm->_graphicsManager.min_y - (int16)v2)
|
2012-10-22 12:18:10 +00:00
|
|
|
yp = _vm->_graphicsManager.min_y - (int16)v2;
|
2012-12-11 00:53:50 +00:00
|
|
|
if (_mouseSizeX + v15 >= _vm->_graphicsManager.max_x)
|
|
|
|
v14 = _mouseSizeX - (_mouseSizeX + v15 - _vm->_graphicsManager.max_x - v1);
|
|
|
|
if (yp + _mouseSizeY < v2 + _vm->_graphicsManager.max_y)
|
2012-09-23 00:59:52 +00:00
|
|
|
goto LABEL_34;
|
2012-12-11 00:53:50 +00:00
|
|
|
v3 = v2 + yp + _mouseSizeY - _vm->_graphicsManager.max_y;
|
2012-09-23 00:59:52 +00:00
|
|
|
}
|
2012-12-11 00:53:50 +00:00
|
|
|
v13 = _mouseSizeY - v3;
|
2012-09-23 00:59:52 +00:00
|
|
|
LABEL_34:
|
|
|
|
v12 = v14 + v15;
|
2012-10-13 07:27:14 +00:00
|
|
|
v11 = yp + v13;
|
2012-09-23 00:59:52 +00:00
|
|
|
}
|
|
|
|
LABEL_35:
|
|
|
|
if (!_vm->_globals.PUBEXIT)
|
2012-12-16 13:22:24 +00:00
|
|
|
_vm->_objectsManager.displaySprite();
|
2012-12-11 00:53:50 +00:00
|
|
|
if (_mouseFl != true) {
|
2012-11-23 10:55:17 +00:00
|
|
|
updateCursor();
|
2012-09-23 00:59:52 +00:00
|
|
|
goto LABEL_54;
|
2012-11-23 10:55:17 +00:00
|
|
|
}
|
2012-12-11 07:31:07 +00:00
|
|
|
if (_mouseCursorId == 23)
|
2012-09-23 00:59:52 +00:00
|
|
|
goto LABEL_45;
|
2012-10-13 07:27:14 +00:00
|
|
|
if (yp >= _vm->_graphicsManager.max_y || v15 >= _vm->_graphicsManager.max_x || v14 <= 1 || v13 <= 1) {
|
2012-12-11 07:31:07 +00:00
|
|
|
if (_mouseCursorId != 23)
|
2012-09-23 00:59:52 +00:00
|
|
|
goto LABEL_54;
|
|
|
|
LABEL_45:
|
2012-10-13 07:27:14 +00:00
|
|
|
if (yp < _vm->_graphicsManager.max_y && v15 < _vm->_graphicsManager.max_x) {
|
|
|
|
if ((signed int)(v14 + v15) > _vm->_graphicsManager.max_x)
|
|
|
|
v14 -= v14 + v15 - _vm->_graphicsManager.max_x;
|
|
|
|
if (yp + v13 > _vm->_graphicsManager.max_y)
|
|
|
|
v13 -= yp + v13 - _vm->_graphicsManager.max_y;
|
|
|
|
if (v14 > 1 && v13 > 1) {
|
2012-11-01 11:35:33 +00:00
|
|
|
_vm->_eventsManager.updateCursor();
|
2012-09-23 00:59:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
goto LABEL_54;
|
|
|
|
}
|
2012-10-13 07:41:55 +00:00
|
|
|
|
2012-11-21 10:59:35 +00:00
|
|
|
_vm->_eventsManager.updateCursor();
|
2012-10-13 07:27:14 +00:00
|
|
|
_vm->_graphicsManager.Ajoute_Segment_Vesa(v15, yp, v12, v11);
|
2012-09-23 00:59:52 +00:00
|
|
|
LABEL_54:
|
2012-12-17 07:01:29 +00:00
|
|
|
_vm->_globals._speed = 2;
|
2012-09-23 00:59:52 +00:00
|
|
|
do {
|
2012-10-13 07:27:14 +00:00
|
|
|
while (!_vm->shouldQuit()) {
|
|
|
|
checkForNextFrameCounter();
|
2012-09-23 00:59:52 +00:00
|
|
|
|
2012-12-11 00:53:50 +00:00
|
|
|
while (_breakoutFl || _vm->_globals.iRegul != 1) {
|
2012-11-18 09:58:53 +00:00
|
|
|
checkForNextFrameCounter();
|
|
|
|
|
2012-12-11 00:53:50 +00:00
|
|
|
if (_breakoutFl != true)
|
2012-09-23 00:59:52 +00:00
|
|
|
goto LABEL_63;
|
2012-12-11 07:31:07 +00:00
|
|
|
if (_rateCounter > 1)
|
2012-09-23 00:59:52 +00:00
|
|
|
goto LABEL_65;
|
|
|
|
}
|
2012-12-17 07:01:29 +00:00
|
|
|
if (_vm->_globals._speed != 2)
|
2012-09-23 00:59:52 +00:00
|
|
|
break;
|
2012-12-11 07:31:07 +00:00
|
|
|
if (_rateCounter > 9)
|
2012-09-23 00:59:52 +00:00
|
|
|
goto LABEL_65;
|
|
|
|
}
|
|
|
|
LABEL_63:
|
|
|
|
;
|
2012-12-11 07:31:07 +00:00
|
|
|
} while (!_vm->shouldQuit() && _vm->_globals.iRegul == 3 && _rateCounter <= 15);
|
2012-09-23 00:59:52 +00:00
|
|
|
LABEL_65:
|
2012-12-17 07:01:29 +00:00
|
|
|
_vm->_globals._speed = 2;
|
2012-12-11 07:31:07 +00:00
|
|
|
_rateCounter = 0;
|
2012-12-15 23:26:54 +00:00
|
|
|
if (!_vm->_graphicsManager.DOUBLE_ECRAN || _vm->_graphicsManager.no_scroll == 1) {
|
2012-10-13 07:27:14 +00:00
|
|
|
_vm->_graphicsManager.Affiche_Segment_Vesa();
|
2012-09-23 00:59:52 +00:00
|
|
|
} else {
|
2012-10-13 07:27:14 +00:00
|
|
|
if (_vm->_graphicsManager.no_scroll != 2) {
|
2012-12-11 00:53:50 +00:00
|
|
|
if (getMouseX() > _vm->_graphicsManager.SCROLL + 620)
|
2012-10-13 07:27:14 +00:00
|
|
|
_vm->_graphicsManager.SCROLL += _vm->_graphicsManager.SPEED_SCROLL;
|
2012-12-11 00:53:50 +00:00
|
|
|
if (getMouseX() < _vm->_graphicsManager.SCROLL + 10)
|
2012-10-13 07:27:14 +00:00
|
|
|
_vm->_graphicsManager.SCROLL -= _vm->_graphicsManager.SPEED_SCROLL;
|
2012-09-23 00:59:52 +00:00
|
|
|
}
|
2012-10-13 07:27:14 +00:00
|
|
|
if (_vm->_graphicsManager.SCROLL < 0)
|
|
|
|
_vm->_graphicsManager.SCROLL = 0;
|
2012-11-25 10:25:14 +00:00
|
|
|
if (_vm->_graphicsManager.SCROLL > SCREEN_WIDTH)
|
|
|
|
_vm->_graphicsManager.SCROLL = SCREEN_WIDTH;
|
2012-12-15 23:26:54 +00:00
|
|
|
if (_vm->_graphicsManager.OLD_SCROLL == _vm->_graphicsManager.SCROLL) {
|
2012-10-13 07:27:14 +00:00
|
|
|
_vm->_graphicsManager.Affiche_Segment_Vesa();
|
2012-09-23 00:59:52 +00:00
|
|
|
} else {
|
2012-12-11 23:22:18 +00:00
|
|
|
_vm->_fontManager.hideText(9);
|
2012-12-19 01:15:32 +00:00
|
|
|
_vm->_graphicsManager.lockScreen();
|
|
|
|
_vm->_graphicsManager.m_scroll16(_vm->_graphicsManager._vesaBuffer, _vm->_graphicsManager.SCROLL, 20, SCREEN_WIDTH, 440, 0, 20);
|
|
|
|
_vm->_graphicsManager.unlockScreen();
|
2012-12-15 23:26:54 +00:00
|
|
|
_vm->_graphicsManager.dstrect[0] = Common::Rect(0, 20, SCREEN_WIDTH, 460);
|
2012-11-23 21:21:35 +00:00
|
|
|
|
2012-12-22 00:28:31 +00:00
|
|
|
for (int i = 1; i < _vm->_globals.NBBLOC + 1; i++) {
|
|
|
|
if (_vm->_globals.BLOC[i]._activeFl)
|
|
|
|
_vm->_globals.BLOC[i]._activeFl = false;
|
2012-09-23 00:59:52 +00:00
|
|
|
}
|
2012-12-22 00:28:31 +00:00
|
|
|
|
2012-09-23 00:59:52 +00:00
|
|
|
_vm->_globals.NBBLOC = 0;
|
2012-12-15 23:26:54 +00:00
|
|
|
_startPos.x = _vm->_graphicsManager.SCROLL;
|
|
|
|
_vm->_graphicsManager.ofscroll = _vm->_graphicsManager.SCROLL;
|
|
|
|
_vm->_graphicsManager.SCROLL = _vm->_graphicsManager.SCROLL;
|
2012-09-23 00:59:52 +00:00
|
|
|
}
|
2012-12-15 23:26:54 +00:00
|
|
|
_vm->_graphicsManager.OLD_SCROLL = _vm->_graphicsManager.SCROLL;
|
|
|
|
_startPos.x = _vm->_graphicsManager.SCROLL;
|
|
|
|
_vm->_graphicsManager.ofscroll = _vm->_graphicsManager.SCROLL;
|
2012-09-23 00:59:52 +00:00
|
|
|
}
|
2012-12-11 07:31:07 +00:00
|
|
|
_curMouseButton = _mouseButton;
|
|
|
|
_mouseButton = 0;
|
2012-09-23 00:59:52 +00:00
|
|
|
_vm->_soundManager.VERIF_SOUND();
|
2012-12-11 07:31:07 +00:00
|
|
|
refreshEvents();
|
2012-12-14 00:49:22 +00:00
|
|
|
}
|
2012-09-23 00:59:52 +00:00
|
|
|
|
2012-11-01 11:35:33 +00:00
|
|
|
void EventsManager::updateCursor() {
|
|
|
|
// Backup the current sprite clipping bounds and reset them
|
|
|
|
Common::Rect clipBounds(_vm->_graphicsManager.min_x, _vm->_graphicsManager.min_y,
|
|
|
|
_vm->_graphicsManager.max_x, _vm->_graphicsManager.max_y);
|
|
|
|
_vm->_graphicsManager.min_x = _vm->_graphicsManager.min_y = 0;
|
2012-12-19 07:00:22 +00:00
|
|
|
_vm->_graphicsManager.max_x = _vm->_globals._objectWidth;
|
|
|
|
_vm->_graphicsManager.max_y = _vm->_globals._objectHeight;
|
|
|
|
int pitch = _vm->_graphicsManager._lineNbr2;
|
|
|
|
_vm->_graphicsManager._lineNbr2 = _vm->_globals._objectWidth;
|
2012-11-01 11:35:33 +00:00
|
|
|
|
|
|
|
// Create the temporary cursor surface
|
2012-12-19 07:00:22 +00:00
|
|
|
byte *cursorSurface = new byte[_vm->_globals._objectHeight * _vm->_globals._objectWidth];
|
|
|
|
Common::fill(cursorSurface, cursorSurface + _vm->_globals._objectHeight * _vm->_globals._objectWidth, 0);
|
2012-11-01 11:35:33 +00:00
|
|
|
|
2012-12-11 07:31:07 +00:00
|
|
|
if (_mouseCursorId != 23) {
|
2012-11-01 11:35:33 +00:00
|
|
|
// Draw standard cursor
|
2012-12-11 07:31:07 +00:00
|
|
|
_vm->_graphicsManager.Sprite_Vesa(cursorSurface, _mouseCursor, 300, 300, _mouseSpriteId);
|
2012-11-01 11:35:33 +00:00
|
|
|
} else {
|
|
|
|
// Draw the active inventory object
|
2012-12-11 00:53:50 +00:00
|
|
|
_vm->_graphicsManager.Affiche_Perfect(cursorSurface, _objectBuf, 300, 300, 0, 0, 0, 0);
|
2012-11-01 11:35:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Reset the clipping bounds
|
|
|
|
_vm->_graphicsManager.min_x = clipBounds.left;
|
|
|
|
_vm->_graphicsManager.min_y = clipBounds.top;
|
|
|
|
_vm->_graphicsManager.max_x = clipBounds.right;
|
|
|
|
_vm->_graphicsManager.max_y = clipBounds.bottom;
|
2012-12-19 07:00:22 +00:00
|
|
|
_vm->_graphicsManager._lineNbr2 = pitch;
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-11-01 11:35:33 +00:00
|
|
|
// Convert the cursor to the pixel format. At the moment, it's hardcoded
|
|
|
|
// to expect the game to be in 16-bit mode
|
2012-12-19 07:00:22 +00:00
|
|
|
uint16 *cursorPixels = new uint16[_vm->_globals._objectHeight * _vm->_globals._objectWidth];
|
2012-11-01 11:35:33 +00:00
|
|
|
const byte *srcP = cursorSurface;
|
|
|
|
uint16 *destP = cursorPixels;
|
|
|
|
|
2012-12-19 07:00:22 +00:00
|
|
|
for (int yp = 0; yp < _vm->_globals._objectHeight; ++yp) {
|
2012-11-01 11:35:33 +00:00
|
|
|
const byte *lineSrcP = srcP;
|
|
|
|
uint16 *lineDestP = destP;
|
|
|
|
|
2012-12-19 07:00:22 +00:00
|
|
|
for (int xp = 0; xp < _vm->_globals._objectWidth; ++xp)
|
2012-11-01 11:35:33 +00:00
|
|
|
*lineDestP++ = *(uint16 *)&_vm->_graphicsManager.PAL_PIXELS[*lineSrcP++ * 2];
|
|
|
|
|
2012-12-19 07:00:22 +00:00
|
|
|
srcP += _vm->_globals._objectWidth;
|
|
|
|
destP += _vm->_globals._objectWidth;
|
2012-11-01 11:35:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Calculate the X offset within the pointer image to the actual cursor data
|
2012-12-11 00:53:50 +00:00
|
|
|
int xOffset = !_mouseLinuxFl ? 10 : 20;
|
2012-11-01 11:35:33 +00:00
|
|
|
|
|
|
|
// Set the ScummVM cursor from the surface
|
|
|
|
Graphics::PixelFormat pixelFormat = g_system->getScreenFormat();
|
2012-12-19 07:00:22 +00:00
|
|
|
CursorMan.replaceCursor(cursorPixels, _vm->_globals._objectWidth, _vm->_globals._objectHeight,
|
2012-11-17 11:09:04 +00:00
|
|
|
xOffset, 0, *((uint16 *)cursorPixels), true, &pixelFormat);
|
2012-11-01 11:35:33 +00:00
|
|
|
|
2012-12-14 00:49:22 +00:00
|
|
|
// Delete the cursor surface
|
2012-11-01 11:35:33 +00:00
|
|
|
delete[] cursorPixels;
|
|
|
|
delete[] cursorSurface;
|
|
|
|
}
|
|
|
|
|
2012-09-08 08:45:22 +00:00
|
|
|
} // End of namespace Hopkins
|