2009-02-17 15:02:16 +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.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
2009-02-15 06:10:59 +00:00
|
|
|
|
2009-05-13 16:52:41 +00:00
|
|
|
#include "sci/sci.h"
|
2010-02-13 17:44:58 +00:00
|
|
|
#include "sci/engine/features.h"
|
2009-02-27 02:23:40 +00:00
|
|
|
#include "sci/engine/state.h"
|
2010-01-29 11:03:54 +00:00
|
|
|
#include "sci/engine/selector.h"
|
2009-02-24 05:51:55 +00:00
|
|
|
#include "sci/engine/kernel.h"
|
2009-06-04 11:28:05 +00:00
|
|
|
#include "sci/console.h"
|
|
|
|
#include "sci/debug.h" // for g_debug_simulated_key
|
2009-12-04 17:38:24 +00:00
|
|
|
#include "sci/event.h"
|
2010-02-05 18:56:13 +00:00
|
|
|
#include "sci/graphics/coordadjuster.h"
|
2010-01-05 01:37:57 +00:00
|
|
|
#include "sci/graphics/cursor.h"
|
2009-02-15 06:10:59 +00:00
|
|
|
|
2009-02-21 10:23:36 +00:00
|
|
|
namespace Sci {
|
|
|
|
|
2009-02-15 06:10:59 +00:00
|
|
|
#define SCI_VARIABLE_GAME_SPEED 3
|
|
|
|
|
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
|
|
|
reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) {
|
2009-06-07 15:53:30 +00:00
|
|
|
int mask = argv[0].toUint16();
|
2009-02-15 06:10:59 +00:00
|
|
|
reg_t obj = argv[1];
|
2010-06-17 23:11:12 +00:00
|
|
|
SciEvent curEvent;
|
2009-02-15 06:10:59 +00:00
|
|
|
int oldx, oldy;
|
2009-12-04 17:58:26 +00:00
|
|
|
int modifier_mask = getSciVersion() <= SCI_VERSION_01 ? SCI_KEYMOD_ALL : SCI_KEYMOD_NO_FOOLOCK;
|
2009-10-04 18:38:18 +00:00
|
|
|
SegManager *segMan = s->_segMan;
|
2010-01-29 21:30:46 +00:00
|
|
|
Common::Point mousePos;
|
|
|
|
|
2010-06-03 21:52:21 +00:00
|
|
|
// Limit the mouse cursor position, if necessary
|
|
|
|
g_sci->_gfxCursor->refreshPosition();
|
2010-02-13 17:43:31 +00:00
|
|
|
mousePos = g_sci->_gfxCursor->getPosition();
|
2009-02-15 06:10:59 +00:00
|
|
|
|
2009-02-19 18:40:03 +00:00
|
|
|
// If there's a simkey pending, and the game wants a keyboard event, use the
|
|
|
|
// simkey instead of a normal event
|
2009-12-04 17:58:26 +00:00
|
|
|
if (g_debug_simulated_key && (mask & SCI_EVENT_KEYBOARD)) {
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelectorValue(segMan, obj, SELECTOR(type), SCI_EVENT_KEYBOARD); // Keyboard event
|
|
|
|
writeSelectorValue(segMan, obj, SELECTOR(message), g_debug_simulated_key);
|
|
|
|
writeSelectorValue(segMan, obj, SELECTOR(modifiers), SCI_KEYMOD_NUMLOCK); // Numlock on
|
|
|
|
writeSelectorValue(segMan, obj, SELECTOR(x), mousePos.x);
|
|
|
|
writeSelectorValue(segMan, obj, SELECTOR(y), mousePos.y);
|
2009-06-04 11:28:05 +00:00
|
|
|
g_debug_simulated_key = 0;
|
2009-02-15 06:10:59 +00:00
|
|
|
return make_reg(0, 1);
|
|
|
|
}
|
2009-02-15 22:28:12 +00:00
|
|
|
|
2009-10-07 21:29:47 +00:00
|
|
|
oldx = mousePos.x;
|
|
|
|
oldy = mousePos.y;
|
2010-06-17 23:10:37 +00:00
|
|
|
curEvent = g_sci->getEventManager()->getSciEvent(mask);
|
2009-02-15 06:10:59 +00:00
|
|
|
|
2010-06-01 15:11:20 +00:00
|
|
|
if (g_sci->getVocabulary())
|
|
|
|
g_sci->getVocabulary()->parser_event = NULL_REG; // Invalidate parser event
|
2009-02-15 06:10:59 +00:00
|
|
|
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelectorValue(segMan, obj, SELECTOR(x), mousePos.x);
|
|
|
|
writeSelectorValue(segMan, obj, SELECTOR(y), mousePos.y);
|
2009-02-15 06:10:59 +00:00
|
|
|
|
2009-10-07 21:29:47 +00:00
|
|
|
//s->_gui->moveCursor(s->gfx_state->pointer_pos.x, s->gfx_state->pointer_pos.y);
|
2009-02-15 06:10:59 +00:00
|
|
|
|
2009-12-04 17:38:24 +00:00
|
|
|
switch (curEvent.type) {
|
2009-12-04 17:58:26 +00:00
|
|
|
case SCI_EVENT_QUIT:
|
2010-06-08 21:05:46 +00:00
|
|
|
s->abortScriptProcessing = kAbortQuitGame; // Terminate VM
|
2010-06-08 18:44:27 +00:00
|
|
|
g_debugState.seeking = kDebugSeekNothing;
|
|
|
|
g_debugState.runningStep = 0;
|
2009-02-15 22:28:12 +00:00
|
|
|
break;
|
2009-02-15 06:10:59 +00:00
|
|
|
|
2009-12-04 17:58:26 +00:00
|
|
|
case SCI_EVENT_KEYBOARD:
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelectorValue(segMan, obj, SELECTOR(type), SCI_EVENT_KEYBOARD); // Keyboard event
|
2009-12-31 17:43:54 +00:00
|
|
|
s->r_acc = make_reg(0, 1);
|
|
|
|
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelectorValue(segMan, obj, SELECTOR(message), curEvent.character);
|
2009-12-31 17:43:54 +00:00
|
|
|
// We only care about the translated character
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelectorValue(segMan, obj, SELECTOR(modifiers), curEvent.modifiers & modifier_mask);
|
2009-02-26 02:21:55 +00:00
|
|
|
break;
|
2009-02-15 22:28:12 +00:00
|
|
|
|
2009-12-04 17:58:26 +00:00
|
|
|
case SCI_EVENT_MOUSE_RELEASE:
|
|
|
|
case SCI_EVENT_MOUSE_PRESS:
|
2009-02-15 22:28:12 +00:00
|
|
|
|
2009-05-30 20:01:43 +00:00
|
|
|
// track left buttton clicks, if requested
|
2009-12-04 17:58:26 +00:00
|
|
|
if (curEvent.type == SCI_EVENT_MOUSE_PRESS && curEvent.data == 1 && g_debug_track_mouse_clicks) {
|
2010-02-13 17:42:49 +00:00
|
|
|
g_sci->getSciDebugger()->DebugPrintf("Mouse clicked at %d, %d\n",
|
2009-10-07 21:29:47 +00:00
|
|
|
mousePos.x, mousePos.y);
|
2009-05-30 20:01:43 +00:00
|
|
|
}
|
|
|
|
|
2009-12-04 17:38:24 +00:00
|
|
|
if (mask & curEvent.type) {
|
2009-10-07 22:45:50 +00:00
|
|
|
int extra_bits = 0;
|
|
|
|
|
2009-12-04 17:38:24 +00:00
|
|
|
switch (curEvent.data) {
|
2009-02-15 22:28:12 +00:00
|
|
|
case 2:
|
2009-12-04 17:58:26 +00:00
|
|
|
extra_bits = SCI_KEYMOD_LSHIFT | SCI_KEYMOD_RSHIFT;
|
2009-02-15 22:28:12 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2009-12-04 17:58:26 +00:00
|
|
|
extra_bits = SCI_KEYMOD_CTRL;
|
2009-02-15 22:28:12 +00:00
|
|
|
default:
|
|
|
|
break;
|
2009-02-15 06:10:59 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelectorValue(segMan, obj, SELECTOR(type), curEvent.type);
|
|
|
|
writeSelectorValue(segMan, obj, SELECTOR(message), 0);
|
|
|
|
writeSelectorValue(segMan, obj, SELECTOR(modifiers), (curEvent.modifiers | extra_bits) & modifier_mask);
|
2009-02-15 22:28:12 +00:00
|
|
|
s->r_acc = make_reg(0, 1);
|
2009-02-15 06:10:59 +00:00
|
|
|
}
|
2009-02-26 02:21:55 +00:00
|
|
|
break;
|
2009-02-15 22:28:12 +00:00
|
|
|
|
2009-02-26 02:21:55 +00:00
|
|
|
default:
|
2009-02-19 18:40:03 +00:00
|
|
|
s->r_acc = NULL_REG; // Unknown or no event
|
2009-02-15 22:28:12 +00:00
|
|
|
}
|
2009-02-15 06:10:59 +00:00
|
|
|
|
2009-09-17 13:21:19 +00:00
|
|
|
if ((s->r_acc.offset) && (g_debugState.stopOnEvent)) {
|
|
|
|
g_debugState.stopOnEvent = false;
|
2009-06-06 16:43:13 +00:00
|
|
|
|
2010-06-15 12:33:20 +00:00
|
|
|
// A SCI event occurred, and we have been asked to stop, so open the debug console
|
2010-02-13 17:42:49 +00:00
|
|
|
Console *con = g_sci->getSciDebugger();
|
2010-06-15 12:33:20 +00:00
|
|
|
con->DebugPrintf("SCI event occurred: ");
|
2009-12-04 17:38:24 +00:00
|
|
|
switch (curEvent.type) {
|
2009-12-04 17:58:26 +00:00
|
|
|
case SCI_EVENT_QUIT:
|
2009-06-06 16:43:13 +00:00
|
|
|
con->DebugPrintf("quit event\n");
|
|
|
|
break;
|
2009-12-04 17:58:26 +00:00
|
|
|
case SCI_EVENT_KEYBOARD:
|
2009-06-06 16:43:13 +00:00
|
|
|
con->DebugPrintf("keyboard event\n");
|
|
|
|
break;
|
2009-12-04 17:58:26 +00:00
|
|
|
case SCI_EVENT_MOUSE_RELEASE:
|
|
|
|
case SCI_EVENT_MOUSE_PRESS:
|
2009-06-06 16:43:13 +00:00
|
|
|
con->DebugPrintf("mouse click event\n");
|
|
|
|
break;
|
|
|
|
default:
|
2009-12-04 17:38:24 +00:00
|
|
|
con->DebugPrintf("unknown or no event (event type %d)\n", curEvent.type);
|
2009-06-06 16:43:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
con->attach();
|
|
|
|
con->onFrame();
|
2009-02-15 22:28:12 +00:00
|
|
|
}
|
2009-02-15 06:10:59 +00:00
|
|
|
|
2010-01-04 16:16:58 +00:00
|
|
|
#ifndef USE_OLD_MUSIC_FUNCTIONS
|
2010-02-13 17:44:58 +00:00
|
|
|
if (g_sci->_features->detectDoSoundType() <= SCI_VERSION_0_LATE) {
|
2010-01-04 16:16:58 +00:00
|
|
|
// If we're running a SCI0 game, update the sound cues, to compensate
|
|
|
|
// for the fact that SCI0 does not poll to update the sound cues itself,
|
2010-01-04 16:18:35 +00:00
|
|
|
// like SCI01 and later do with cmdUpdateSoundCues. kGetEvent is called
|
2010-01-04 16:16:58 +00:00
|
|
|
// quite often, so emulate the SCI01 behavior of cmdUpdateSoundCues with
|
|
|
|
// this call
|
|
|
|
s->_soundCmd->updateSci0Cues();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-02-15 06:10:59 +00:00
|
|
|
return s->r_acc;
|
|
|
|
}
|
|
|
|
|
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
|
|
|
reg_t kMapKeyToDir(EngineState *s, int argc, reg_t *argv) {
|
2009-02-15 06:10:59 +00:00
|
|
|
reg_t obj = argv[0];
|
2009-10-04 18:38:18 +00:00
|
|
|
SegManager *segMan = s->_segMan;
|
2009-02-15 06:10:59 +00:00
|
|
|
|
2010-05-29 23:37:15 +00:00
|
|
|
if (readSelectorValue(segMan, obj, SELECTOR(type)) == SCI_EVENT_KEYBOARD) { // Keyboard
|
2009-02-15 06:10:59 +00:00
|
|
|
int mover = -1;
|
2010-05-29 23:37:15 +00:00
|
|
|
switch (readSelectorValue(segMan, obj, SELECTOR(message))) {
|
2009-12-04 17:58:26 +00:00
|
|
|
case SCI_KEY_HOME:
|
2009-02-15 22:28:12 +00:00
|
|
|
mover = 8;
|
|
|
|
break;
|
2009-12-04 17:58:26 +00:00
|
|
|
case SCI_KEY_UP:
|
2009-02-15 22:28:12 +00:00
|
|
|
mover = 1;
|
|
|
|
break;
|
2009-12-04 17:58:26 +00:00
|
|
|
case SCI_KEY_PGUP:
|
2009-02-15 22:28:12 +00:00
|
|
|
mover = 2;
|
|
|
|
break;
|
2009-12-04 17:58:26 +00:00
|
|
|
case SCI_KEY_LEFT:
|
2009-02-15 22:28:12 +00:00
|
|
|
mover = 7;
|
|
|
|
break;
|
2009-12-04 17:58:26 +00:00
|
|
|
case SCI_KEY_CENTER:
|
2009-02-15 22:28:12 +00:00
|
|
|
case 76:
|
|
|
|
mover = 0;
|
|
|
|
break;
|
2009-12-04 17:58:26 +00:00
|
|
|
case SCI_KEY_RIGHT:
|
2009-02-15 22:28:12 +00:00
|
|
|
mover = 3;
|
|
|
|
break;
|
2009-12-04 17:58:26 +00:00
|
|
|
case SCI_KEY_END:
|
2009-02-15 22:28:12 +00:00
|
|
|
mover = 6;
|
|
|
|
break;
|
2009-12-04 17:58:26 +00:00
|
|
|
case SCI_KEY_DOWN:
|
2009-02-15 22:28:12 +00:00
|
|
|
mover = 5;
|
|
|
|
break;
|
2009-12-04 17:58:26 +00:00
|
|
|
case SCI_KEY_PGDOWN:
|
2009-02-15 22:28:12 +00:00
|
|
|
mover = 4;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2009-02-15 06:10:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mover >= 0) {
|
2010-06-19 09:46:04 +00:00
|
|
|
if (g_sci->getEventManager()->getUsesNewKeyboardDirectionType())
|
|
|
|
writeSelectorValue(segMan, obj, SELECTOR(type), SCI_EVENT_KEYBOARD | SCI_EVENT_DIRECTION);
|
2010-06-18 22:16:05 +00:00
|
|
|
else
|
2010-06-19 09:46:04 +00:00
|
|
|
writeSelectorValue(segMan, obj, SELECTOR(type), SCI_EVENT_DIRECTION);
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelectorValue(segMan, obj, SELECTOR(message), mover);
|
2009-02-15 06:10:59 +00:00
|
|
|
return make_reg(0, 1);
|
2009-02-26 02:21:55 +00:00
|
|
|
} else
|
|
|
|
return NULL_REG;
|
2009-02-15 06:10:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return s->r_acc;
|
|
|
|
}
|
|
|
|
|
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
|
|
|
reg_t kGlobalToLocal(EngineState *s, int argc, reg_t *argv) {
|
2009-02-19 18:40:03 +00:00
|
|
|
reg_t obj = argc ? argv[0] : NULL_REG; // Can this really happen? Lars
|
2010-02-05 18:56:13 +00:00
|
|
|
reg_t planeObject = argc > 1 ? argv[1] : NULL_REG; // SCI32
|
2009-10-04 18:38:18 +00:00
|
|
|
SegManager *segMan = s->_segMan;
|
2009-02-15 06:10:59 +00:00
|
|
|
|
|
|
|
if (obj.segment) {
|
2010-05-29 23:37:15 +00:00
|
|
|
int16 x = readSelectorValue(segMan, obj, SELECTOR(x));
|
|
|
|
int16 y = readSelectorValue(segMan, obj, SELECTOR(y));
|
2009-02-15 06:10:59 +00:00
|
|
|
|
2010-02-13 17:43:31 +00:00
|
|
|
g_sci->_gfxCoordAdjuster->kernelGlobalToLocal(x, y, planeObject);
|
2009-10-03 20:49:18 +00:00
|
|
|
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelectorValue(segMan, obj, SELECTOR(x), x);
|
|
|
|
writeSelectorValue(segMan, obj, SELECTOR(y), y);
|
2009-02-15 06:10:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return s->r_acc;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
|
|
|
reg_t kLocalToGlobal(EngineState *s, int argc, reg_t *argv) {
|
2009-02-19 18:40:03 +00:00
|
|
|
reg_t obj = argc ? argv[0] : NULL_REG; // Can this really happen? Lars
|
2010-02-05 18:56:13 +00:00
|
|
|
reg_t planeObject = argc > 1 ? argv[1] : NULL_REG; // SCI32
|
2009-10-04 18:38:18 +00:00
|
|
|
SegManager *segMan = s->_segMan;
|
2009-02-15 06:10:59 +00:00
|
|
|
|
|
|
|
if (obj.segment) {
|
2010-05-29 23:37:15 +00:00
|
|
|
int16 x = readSelectorValue(segMan, obj, SELECTOR(x));
|
|
|
|
int16 y = readSelectorValue(segMan, obj, SELECTOR(y));
|
2009-10-03 20:49:18 +00:00
|
|
|
|
2010-02-13 17:43:31 +00:00
|
|
|
g_sci->_gfxCoordAdjuster->kernelLocalToGlobal(x, y, planeObject);
|
2009-02-15 06:10:59 +00:00
|
|
|
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelectorValue(segMan, obj, SELECTOR(x), x);
|
|
|
|
writeSelectorValue(segMan, obj, SELECTOR(y), y);
|
2009-02-15 06:10:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return s->r_acc;
|
|
|
|
}
|
|
|
|
|
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
|
|
|
reg_t kJoystick(EngineState *s, int argc, reg_t *argv) {
|
2009-05-16 14:24:12 +00:00
|
|
|
// Subfunction 12 sets/gets joystick repeat rate
|
|
|
|
debug(5, "Unimplemented syscall 'Joystick()'");
|
2009-02-15 06:10:59 +00:00
|
|
|
return NULL_REG;
|
|
|
|
}
|
2009-02-21 10:23:36 +00:00
|
|
|
|
|
|
|
} // End of namespace Sci
|