aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2008-04-26 22:13:19 +0000
committerJohannes Schickel2008-04-26 22:13:19 +0000
commit6ed2d9c28701931b3633b638ad736f371f4024cf (patch)
tree291026e925b441fe73836ee4b806db182ed470ab
parentfa208a43867f2c0763ef6e21d31c5015438f921b (diff)
downloadscummvm-rg350-6ed2d9c28701931b3633b638ad736f371f4024cf.tar.gz
scummvm-rg350-6ed2d9c28701931b3633b638ad736f371f4024cf.tar.bz2
scummvm-rg350-6ed2d9c28701931b3633b638ad736f371f4024cf.zip
Implemented opcodes:
- 26: o3_setInventorySlot - 27: o3_getInventorySlot - 28: o3_addItemToInventory svn-id: r31737
-rw-r--r--engines/kyra/items_v3.cpp9
-rw-r--r--engines/kyra/kyra_v3.h5
-rw-r--r--engines/kyra/script_v3.cpp31
3 files changed, 42 insertions, 3 deletions
diff --git a/engines/kyra/items_v3.cpp b/engines/kyra/items_v3.cpp
index 4417ba4aa5..aecf4337ce 100644
--- a/engines/kyra/items_v3.cpp
+++ b/engines/kyra/items_v3.cpp
@@ -64,6 +64,15 @@ int KyraEngine_v3::findFreeItem() {
return -1;
}
+int KyraEngine_v3::findFreeInventorySlot() {
+ debugC(9, kDebugLevelMain, "KyraEngine_v3::findFreeInventorySlot()");
+ for (int i = 0; i < 10; ++i) {
+ if (_mainCharacter.inventory[i] == 0xFFFF)
+ return i;
+ }
+ return -1;
+}
+
int KyraEngine_v3::findItem(uint16 sceneId, uint16 id) {
debugC(9, kDebugLevelMain, "KyraEngine_v3::findItem(%u, %u)", sceneId, id);
for (int i = 0; i < 50; ++i) {
diff --git a/engines/kyra/kyra_v3.h b/engines/kyra/kyra_v3.h
index bb99f1f39d..ac7625e8ee 100644
--- a/engines/kyra/kyra_v3.h
+++ b/engines/kyra/kyra_v3.h
@@ -539,6 +539,8 @@ private:
void makeCharFacingMouse();
+ int findFreeInventorySlot();
+
// talk object
struct TalkObject {
char filename[13];
@@ -704,6 +706,9 @@ private:
int o3_setCharacterAnimFrameFromFacing(ScriptState *script);
int o3_showBadConscience(ScriptState *script);
int o3_hideBadConscience(ScriptState *script);
+ int o3_setInventorySlot(ScriptState *script);
+ int o3_getInventorySlot(ScriptState *script);
+ int o3_addItemToInventory(ScriptState *script);
int o3_addItemToCurScene(ScriptState *script);
int o3_objectChat(ScriptState *script);
int o3_checkForItem(ScriptState *script);
diff --git a/engines/kyra/script_v3.cpp b/engines/kyra/script_v3.cpp
index c4bba4c81d..fd9f95faf0 100644
--- a/engines/kyra/script_v3.cpp
+++ b/engines/kyra/script_v3.cpp
@@ -185,6 +185,31 @@ int KyraEngine_v3::o3_hideBadConscience(ScriptState *script) {
return 0;
}
+int KyraEngine_v3::o3_setInventorySlot(ScriptState *script) {
+ debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_setInventorySlot(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1));
+ const int slot = MAX<int16>(0, MIN<int16>(10, stackPos(0)));
+ return (_mainCharacter.inventory[slot] = stackPos(1));
+}
+
+int KyraEngine_v3::o3_getInventorySlot(ScriptState *script) {
+ debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_getInventorySlot(%p) (%d)", (const void *)script, stackPos(0));
+ return _mainCharacter.inventory[stackPos(0)];
+}
+
+int KyraEngine_v3::o3_addItemToInventory(ScriptState *script) {
+ debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_addItemToInventory(%p) (%d)", (const void *)script, stackPos(0));
+ int slot = findFreeInventorySlot();
+ if (slot >= 0) {
+ _mainCharacter.inventory[slot] = stackPos(0);
+ if (_inventoryState) {
+ _screen->hideMouse();
+ redrawInventory(0);
+ _screen->showMouse();
+ }
+ }
+ return slot;
+}
+
int KyraEngine_v3::o3_addItemToCurScene(ScriptState *script) {
debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_addItemToCurScene(%p) (%d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2));
const uint16 item = stackPos(0);
@@ -1252,10 +1277,10 @@ void KyraEngine_v3::setupOpcodeTable() {
// 0x18
OpcodeUnImpl();
OpcodeUnImpl();
- OpcodeUnImpl();
- OpcodeUnImpl();
+ Opcode(o3_setInventorySlot);
+ Opcode(o3_getInventorySlot);
// 0x1c
- OpcodeUnImpl();
+ Opcode(o3_addItemToInventory);
OpcodeUnImpl();
Opcode(o3_addItemToCurScene);
Opcode(o3_objectChat);