aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWalter van Niftrik2016-03-19 14:18:01 +0100
committerWalter van Niftrik2016-06-06 20:35:49 +0200
commit3f7d5608a9b3cd967c4ceb6fd9bfb5d2e4c19643 (patch)
treebd79dff454a38f4c00e9fe7336a8da5284dd651c
parent8a05a9cbca3c86868e148e09c392c2bd53bc4de0 (diff)
downloadscummvm-rg350-3f7d5608a9b3cd967c4ceb6fd9bfb5d2e4c19643.tar.gz
scummvm-rg350-3f7d5608a9b3cd967c4ceb6fd9bfb5d2e4c19643.tar.bz2
scummvm-rg350-3f7d5608a9b3cd967c4ceb6fd9bfb5d2e4c19643.zip
ADL: Implement a few hires2 opcodes
-rw-r--r--engines/adl/adl.cpp9
-rw-r--r--engines/adl/adl.h1
-rw-r--r--engines/adl/adl_v2.cpp53
-rw-r--r--engines/adl/adl_v2.h6
4 files changed, 60 insertions, 9 deletions
diff --git a/engines/adl/adl.cpp b/engines/adl/adl.cpp
index e6ce0f65e3..b3ac12d8e6 100644
--- a/engines/adl/adl.cpp
+++ b/engines/adl/adl.cpp
@@ -343,6 +343,10 @@ void AdlEngine::setupOpcodeTables() {
Opcode(o1_setRoomPic);
}
+bool AdlEngine::matchesCurrentPic(byte pic) const {
+ return pic == getCurRoom().curPicture;
+}
+
void AdlEngine::clearScreen() const {
_display->setMode(DISPLAY_MODE_MIXED);
_display->clear(0x00);
@@ -369,8 +373,7 @@ void AdlEngine::drawItems() const {
Common::Array<byte>::const_iterator pic;
for (pic = item->roomPictures.begin(); pic != item->roomPictures.end(); ++pic) {
- // IDI_NONE check was added in hires2
- if (*pic == getCurRoom().curPicture || *pic == IDI_NONE) {
+ if (matchesCurrentPic(*pic)) {
drawItem(*item, item->position);
continue;
}
@@ -451,7 +454,7 @@ void AdlEngine::takeItem(byte noun) {
Common::Array<byte>::const_iterator pic;
for (pic = item->roomPictures.begin(); pic != item->roomPictures.end(); ++pic) {
- if (*pic == getCurRoom().curPicture) {
+ if (matchesCurrentPic(*pic)) {
item->room = IDI_NONE;
item->state = IDI_ITEM_DROPPED;
return;
diff --git a/engines/adl/adl.h b/engines/adl/adl.h
index d13e122181..57036b9bb3 100644
--- a/engines/adl/adl.h
+++ b/engines/adl/adl.h
@@ -175,6 +175,7 @@ protected:
virtual void checkInput(byte verb, byte noun);
virtual void setupOpcodeTables();
+ virtual bool matchesCurrentPic(byte pic) const;
// Opcodes
int o1_isItemInRoom(ScriptEnv &e);
diff --git a/engines/adl/adl_v2.cpp b/engines/adl/adl_v2.cpp
index 8af3fc9ffb..61077d5aae 100644
--- a/engines/adl/adl_v2.cpp
+++ b/engines/adl/adl_v2.cpp
@@ -76,14 +76,14 @@ void AdlEngine_v2::setupOpcodeTables() {
Opcode(o1_setLight);
Opcode(o1_setDark);
// 0x0c
- OpcodeUnImpl();
+ Opcode(o2_moveAllItems);
Opcode(o1_quit);
OpcodeUnImpl();
- Opcode(o1_save);
+ Opcode(o1_save); // TODO
// 0x10
- Opcode(o1_restore);
+ Opcode(o1_restore); // TODO
Opcode(o1_restart);
- Opcode(o1_placeItem);
+ Opcode(o2_placeItem);
Opcode(o1_setItemPic);
// 0x14
Opcode(o1_resetPic);
@@ -100,6 +100,10 @@ void AdlEngine_v2::setupOpcodeTables() {
Opcode(o1_setRoomPic);
}
+bool AdlEngine_v2::matchesCurrentPic(byte pic) const {
+ return pic == getCurRoom().curPicture || pic == IDI_NONE;
+}
+
int AdlEngine_v2::o2_isFirstTime(ScriptEnv &e) {
bool oldFlag = getCurRoom().isFirstTime;
@@ -164,8 +168,6 @@ int AdlEngine_v2::o2_moveItem(ScriptEnv &e) {
Item &item = getItem(e.arg(1));
- // Not implemented: set redraw flag if item room == displayed room
-
// Set items that move from inventory to a room to state "dropped"
if (item.room == IDI_NONE && room != IDI_VOID_ROOM)
item.state = IDI_ITEM_DROPPED;
@@ -174,4 +176,43 @@ int AdlEngine_v2::o2_moveItem(ScriptEnv &e) {
return 2;
}
+int AdlEngine_v2::o2_moveAllItems(ScriptEnv &e) {
+ byte room1 = e.arg(1);
+
+ if (room1 == IDI_CUR_ROOM)
+ room1 = _state.room;
+
+ byte room2 = e.arg(2);
+
+ if (room2 == IDI_CUR_ROOM)
+ room2 = _state.room;
+
+ Common::Array<Item>::iterator item;
+
+ for (item = _state.items.begin(); item != _state.items.end(); ++item)
+ if (item->room == room1) {
+ item->room = room2;
+ if (room1 == IDI_NONE)
+ item->state = IDI_ITEM_DROPPED;
+ }
+
+ return 2;
+}
+
+int AdlEngine_v2::o2_placeItem(ScriptEnv &e) {
+ byte room = e.arg(2);
+
+ if (room == IDI_CUR_ROOM)
+ room = _state.room;
+
+ Item &item = getItem(e.arg(1));
+
+ item.room = room;
+ item.position.x = e.arg(3);
+ item.position.y = e.arg(4);
+ item.state = IDI_ITEM_NOT_MOVED;
+
+ return 4;
+}
+
} // End of namespace Adl
diff --git a/engines/adl/adl_v2.h b/engines/adl/adl_v2.h
index 585bd9610c..d6c18e19c3 100644
--- a/engines/adl/adl_v2.h
+++ b/engines/adl/adl_v2.h
@@ -25,6 +25,9 @@
#include "adl/adl.h"
+// Note: this version of ADL redraws only when necessary, but
+// this is not currently implemented.
+
#define IDI_CUR_ROOM 0xfc
#define IDI_VOID_ROOM 0xfd
@@ -42,12 +45,15 @@ protected:
AdlEngine_v2(OSystem *syst, const AdlGameDescription *gd);
virtual void setupOpcodeTables();
+ bool matchesCurrentPic(byte pic) const;
int o2_isFirstTime(ScriptEnv &e);
int o2_isRandomGT(ScriptEnv &e);
int o2_isItemInRoom(ScriptEnv &e);
int o2_isNounNotInRoom(ScriptEnv &e);
int o2_isCarryingSomething(ScriptEnv &e);
+ int o2_moveAllItems(ScriptEnv &e);
+ int o2_placeItem(ScriptEnv &e);
int o2_moveItem(ScriptEnv &e);