aboutsummaryrefslogtreecommitdiff
path: root/engines/draci
diff options
context:
space:
mode:
authorRobert Špalek2009-11-08 21:26:04 +0000
committerRobert Špalek2009-11-08 21:26:04 +0000
commitabbb3dccd7fa909d1746b00a88eb55494514334f (patch)
tree09a8369306bf9ad3e8a0079fd94a74634579543b /engines/draci
parentd5bff15b228d229336b0822cd5b7d6b99213db92 (diff)
downloadscummvm-rg350-abbb3dccd7fa909d1746b00a88eb55494514334f.tar.gz
scummvm-rg350-abbb3dccd7fa909d1746b00a88eb55494514334f.tar.bz2
scummvm-rg350-abbb3dccd7fa909d1746b00a88eb55494514334f.zip
Items put into inventory are placed correctly.
Also, named correctly GPL2 parameter types. This fixes all FIXMEs svn-id: r45762
Diffstat (limited to 'engines/draci')
-rw-r--r--engines/draci/game.cpp11
-rw-r--r--engines/draci/script.cpp134
-rw-r--r--engines/draci/script.h9
3 files changed, 82 insertions, 72 deletions
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp
index aa7964fb3b..efa7d8bf86 100644
--- a/engines/draci/game.cpp
+++ b/engines/draci/game.cpp
@@ -332,9 +332,14 @@ void Game::handleInventoryLoop() {
// Otherwise, if we are holding an item, try to place it inside the
// inventory
} else if (_currentItem != kNoItem) {
- // FIXME: This should place the item in the nearest inventory slot,
- // not the first one available
- putItem(_currentItem, 0);
+ const int column = scummvm_lround(
+ (_vm->_mouse->getPosX() - kInventoryX + kInventoryItemWidth / 2.) /
+ kInventoryItemWidth) - 1;
+ const int line = scummvm_lround(
+ (_vm->_mouse->getPosY() - kInventoryY + kInventoryItemHeight / 2.) /
+ kInventoryItemHeight) - 1;
+ const int index = line * kInventoryColumns + column;
+ putItem(_currentItem, index);
// Remove it from our hands
_currentItem = kNoItem;
diff --git a/engines/draci/script.cpp b/engines/draci/script.cpp
index 70b6c19f0a..e64525626f 100644
--- a/engines/draci/script.cpp
+++ b/engines/draci/script.cpp
@@ -34,88 +34,86 @@
namespace Draci {
-// FIXME: Change parameter types to names once I figure out what they are exactly
-
void Script::setupCommandList() {
/** A table of all the commands the game player uses */
static const GPL2Command gplCommands[] = {
- { 0, 0, "gplend", 0, { 0 }, NULL },
- { 0, 1, "exit", 0, { 0 }, NULL },
- { 1, 1, "goto", 1, { 3 }, &Script::c_Goto },
- { 2, 1, "Let", 2, { 3, 4 }, &Script::c_Let },
- { 3, 1, "if", 2, { 4, 3 }, &Script::c_If },
- { 4, 1, "Start", 2, { 3, 2 }, &Script::start },
- { 5, 1, "Load", 2, { 3, 2 }, &Script::load },
- { 5, 2, "StartPlay", 2, { 3, 2 }, &Script::startPlay },
- { 5, 3, "JustTalk", 0, { 0 }, &Script::justTalk },
- { 5, 4, "JustStay", 0, { 0 }, &Script::justStay },
- { 6, 1, "Talk", 2, { 3, 2 }, &Script::talk },
- { 7, 1, "ObjStat", 2, { 3, 3 }, &Script::objStat },
- { 7, 2, "ObjStat_On", 2, { 3, 3 }, &Script::objStatOn },
- { 8, 1, "IcoStat", 2, { 3, 3 }, &Script::icoStat },
- { 9, 1, "Dialogue", 1, { 2 }, &Script::dialogue },
- { 9, 2, "ExitDialogue", 0, { 0 }, &Script::exitDialogue },
- { 9, 3, "ResetDialogue", 0, { 0 }, &Script::resetDialogue },
- { 9, 4, "ResetDialogueFrom", 0, { 0 }, &Script::resetDialogueFrom },
- { 9, 5, "ResetBlock", 1, { 3 }, &Script::resetBlock },
- { 10, 1, "WalkOn", 3, { 1, 1, 3 }, &Script::walkOn },
- { 10, 2, "StayOn", 3, { 1, 1, 3 }, &Script::stayOn },
- { 10, 3, "WalkOnPlay", 3, { 1, 1, 3 }, &Script::walkOnPlay },
- { 11, 1, "LoadPalette", 1, { 2 }, &Script::loadPalette },
- { 12, 1, "SetPalette", 0, { 0 }, &Script::setPalette },
- { 12, 2, "BlackPalette", 0, { 0 }, &Script::blackPalette },
- { 13, 1, "FadePalette", 3, { 1, 1, 1 }, &Script::fadePalette },
- { 13, 2, "FadePalettePlay", 3, { 1, 1, 1 }, &Script::fadePalettePlay },
- { 14, 1, "NewRoom", 2, { 3, 1 }, &Script::newRoom },
- { 15, 1, "ExecInit", 1, { 3 }, &Script::execInit },
- { 15, 2, "ExecLook", 1, { 3 }, &Script::execLook },
- { 15, 3, "ExecUse", 1, { 3 }, &Script::execUse },
- { 18, 1, "LoadMusic", 1, { 2 }, &Script::loadMusic },
- { 18, 2, "StartMusic", 0, { 0 }, &Script::startMusic },
- { 18, 3, "StopMusic", 0, { 0 }, &Script::stopMusic },
- { 19, 1, "Mark", 0, { 0 }, &Script::mark },
- { 19, 2, "Release", 0, { 0 }, &Script::release },
- { 20, 1, "Play", 0, { 0 }, &Script::play },
- { 21, 1, "LoadMap", 1, { 2 }, &Script::loadMap },
- { 21, 2, "RoomMap", 0, { 0 }, &Script::roomMap },
- { 22, 1, "DisableQuickHero", 0, { 0 }, &Script::disableQuickHero },
- { 22, 2, "EnableQuickHero", 0, { 0 }, &Script::enableQuickHero },
- { 23, 1, "DisableSpeedText", 0, { 0 }, &Script::disableSpeedText },
- { 23, 2, "EnableSpeedText", 0, { 0 }, &Script::enableSpeedText },
- { 24, 1, "QuitGame", 0, { 0 }, &Script::quitGame },
- { 25, 1, "PushNewRoom", 0, { 0 }, &Script::pushNewRoom },
- { 25, 2, "PopNewRoom", 0, { 0 }, &Script::popNewRoom },
+ { 0, 0, "gplend", 0, { }, NULL },
+ { 0, 1, "exit", 0, { }, NULL },
+ { 1, 1, "goto", 1, { kGPL2Ident }, &Script::c_Goto },
+ { 2, 1, "Let", 2, { kGPL2Ident, kGPL2Math }, &Script::c_Let },
+ { 3, 1, "if", 2, { kGPL2Math, kGPL2Ident }, &Script::c_If },
+ { 4, 1, "Start", 2, { kGPL2Ident, kGPL2Str }, &Script::start },
+ { 5, 1, "Load", 2, { kGPL2Ident, kGPL2Str }, &Script::load },
+ { 5, 2, "StartPlay", 2, { kGPL2Ident, kGPL2Str }, &Script::startPlay },
+ { 5, 3, "JustTalk", 0, { }, &Script::justTalk },
+ { 5, 4, "JustStay", 0, { }, &Script::justStay },
+ { 6, 1, "Talk", 2, { kGPL2Ident, kGPL2Str }, &Script::talk },
+ { 7, 1, "ObjStat", 2, { kGPL2Ident, kGPL2Ident }, &Script::objStat },
+ { 7, 2, "ObjStat_On", 2, { kGPL2Ident, kGPL2Ident }, &Script::objStatOn },
+ { 8, 1, "IcoStat", 2, { kGPL2Ident, kGPL2Ident }, &Script::icoStat },
+ { 9, 1, "Dialogue", 1, { kGPL2Str }, &Script::dialogue },
+ { 9, 2, "ExitDialogue", 0, { }, &Script::exitDialogue },
+ { 9, 3, "ResetDialogue", 0, { }, &Script::resetDialogue },
+ { 9, 4, "ResetDialogueFrom", 0, { }, &Script::resetDialogueFrom },
+ { 9, 5, "ResetBlock", 1, { kGPL2Ident }, &Script::resetBlock },
+ { 10, 1, "WalkOn", 3, { kGPL2Num, kGPL2Num, kGPL2Ident }, &Script::walkOn },
+ { 10, 2, "StayOn", 3, { kGPL2Num, kGPL2Num, kGPL2Ident }, &Script::stayOn },
+ { 10, 3, "WalkOnPlay", 3, { kGPL2Num, kGPL2Num, kGPL2Ident }, &Script::walkOnPlay },
+ { 11, 1, "LoadPalette", 1, { kGPL2Str }, &Script::loadPalette },
+ { 12, 1, "SetPalette", 0, { }, &Script::setPalette },
+ { 12, 2, "BlackPalette", 0, { }, &Script::blackPalette },
+ { 13, 1, "FadePalette", 3, { kGPL2Num, kGPL2Num, kGPL2Num }, &Script::fadePalette },
+ { 13, 2, "FadePalettePlay", 3, { kGPL2Num, kGPL2Num, kGPL2Num }, &Script::fadePalettePlay },
+ { 14, 1, "NewRoom", 2, { kGPL2Ident, kGPL2Num }, &Script::newRoom },
+ { 15, 1, "ExecInit", 1, { kGPL2Ident }, &Script::execInit },
+ { 15, 2, "ExecLook", 1, { kGPL2Ident }, &Script::execLook },
+ { 15, 3, "ExecUse", 1, { kGPL2Ident }, &Script::execUse },
+ { 18, 1, "LoadMusic", 1, { kGPL2Str }, &Script::loadMusic },
+ { 18, 2, "StartMusic", 0, { }, &Script::startMusic },
+ { 18, 3, "StopMusic", 0, { }, &Script::stopMusic },
+ { 19, 1, "Mark", 0, { }, &Script::mark },
+ { 19, 2, "Release", 0, { }, &Script::release },
+ { 20, 1, "Play", 0, { }, &Script::play },
+ { 21, 1, "LoadMap", 1, { kGPL2Str }, &Script::loadMap },
+ { 21, 2, "RoomMap", 0, { }, &Script::roomMap },
+ { 22, 1, "DisableQuickHero", 0, { }, &Script::disableQuickHero },
+ { 22, 2, "EnableQuickHero", 0, { }, &Script::enableQuickHero },
+ { 23, 1, "DisableSpeedText", 0, { }, &Script::disableSpeedText },
+ { 23, 2, "EnableSpeedText", 0, { }, &Script::enableSpeedText },
+ { 24, 1, "QuitGame", 0, { }, &Script::quitGame },
+ { 25, 1, "PushNewRoom", 0, { }, &Script::pushNewRoom },
+ { 25, 2, "PopNewRoom", 0, { }, &Script::popNewRoom },
// The following commands are not used in the original game files.
- { 16, 1, "RepaintInventory", 0, { 0 }, NULL },
- { 16, 2, "ExitInventory", 0, { 0 }, NULL },
- { 17, 1, "ExitMap", 0, { 0 }, NULL },
- { 18, 4, "FadeOutMusic", 1, { 1 }, NULL },
- { 18, 5, "FadeInMusic", 1, { 1 }, NULL },
+ { 16, 1, "RepaintInventory", 0, { }, NULL },
+ { 16, 2, "ExitInventory", 0, { }, NULL },
+ { 17, 1, "ExitMap", 0, { }, NULL },
+ { 18, 4, "FadeOutMusic", 1, { kGPL2Num }, NULL },
+ { 18, 5, "FadeInMusic", 1, { kGPL2Num }, NULL },
// The following commands are not even defined in the game
// sources, but their numbers are allocated for internal
// purposes of the old player.
- { 26, 1, "ShowCheat", 0, { 0 }, NULL },
- { 26, 2, "HideCheat", 0, { 0 }, NULL },
- { 26, 3, "ClearCheat", 1, { 1 }, NULL },
- { 27, 1, "FeedPassword", 3, { 1, 1, 1 }, NULL }
+ { 26, 1, "ShowCheat", 0, { }, NULL },
+ { 26, 2, "HideCheat", 0, { }, NULL },
+ { 26, 3, "ClearCheat", 1, { kGPL2Num }, NULL },
+ { 27, 1, "FeedPassword", 3, { kGPL2Num, kGPL2Num, kGPL2Num }, NULL }
};
/** Operators used by the mathematical evaluator */
static const GPL2Operator gplOperators[] = {
- {"&", &Script::operAnd },
- {"|", &Script::operOr },
- {"^", &Script::operXor },
- {"==", &Script::operEqual },
+ {"&", &Script::operAnd },
+ {"|", &Script::operOr },
+ {"^", &Script::operXor },
+ {"==", &Script::operEqual },
{"!=", &Script::operNotEqual },
- {"<", &Script::operLess },
+ {"<", &Script::operLess },
{">", &Script::operGreater },
{"<=", &Script::operLessOrEqual },
{">=", &Script::operGreaterOrEqual },
- {"*", &Script::operMul },
- {"/", &Script::operDiv },
- {"%", &Script::operMod },
- {"+", &Script::operAdd },
- {"-", &Script::operSub }
+ {"*", &Script::operMul },
+ {"/", &Script::operDiv },
+ {"%", &Script::operMod },
+ {"+", &Script::operAdd },
+ {"-", &Script::operSub }
};
/** Functions used by the mathematical evaluator */
@@ -1185,7 +1183,7 @@ void Script::run(const GPL2Program &program, uint16 offset) {
debugC(1, kDraciBytecodeDebugLevel, "%s", cmd->_name);
for (int i = 0; i < cmd->_numParams; ++i) {
- if (cmd->_paramTypes[i] == 4) {
+ if (cmd->_paramTypes[i] == kGPL2Math) {
debugC(3, kDraciBytecodeDebugLevel,
"Evaluating (in-script) GPL expression at offset %d: ", offset);
params.push(handleMathExpression(&reader));
diff --git a/engines/draci/script.h b/engines/draci/script.h
index d145172240..0681172a81 100644
--- a/engines/draci/script.h
+++ b/engines/draci/script.h
@@ -53,12 +53,19 @@ typedef int (Script::*GPLFunctionHandler)(int) const;
* subnumber.
*/
+enum GPL2ParameterType {
+ kGPL2Num = 1,
+ kGPL2Str = 2,
+ kGPL2Ident = 3,
+ kGPL2Math = 4
+};
+
struct GPL2Command {
byte _number;
byte _subNumber;
const char *_name;
uint16 _numParams;
- int _paramTypes[kMaxParams];
+ GPL2ParameterType _paramTypes[kMaxParams];
GPLHandler _handler;
};