aboutsummaryrefslogtreecommitdiff
path: root/engines/dreamweb
diff options
context:
space:
mode:
authorBertrand Augereau2011-09-02 03:55:52 +0200
committerBertrand Augereau2011-09-02 04:33:37 +0200
commit483fae0c564973ff27878133749c51fc8111304f (patch)
tree5eb06ccff8611548d340938dd214fce8a47331fb /engines/dreamweb
parent7b71e9842ee11e5f35256083f3dff63bede0a296 (diff)
downloadscummvm-rg350-483fae0c564973ff27878133749c51fc8111304f.tar.gz
scummvm-rg350-483fae0c564973ff27878133749c51fc8111304f.tar.bz2
scummvm-rg350-483fae0c564973ff27878133749c51fc8111304f.zip
DREAMWEB: 'checkifset' ported to C++
Diffstat (limited to 'engines/dreamweb')
-rw-r--r--engines/dreamweb/dreamgen.cpp42
-rw-r--r--engines/dreamweb/dreamgen.h5
-rw-r--r--engines/dreamweb/stubs.cpp33
-rw-r--r--engines/dreamweb/stubs.h6
-rw-r--r--engines/dreamweb/vgagrafx.cpp4
5 files changed, 39 insertions, 51 deletions
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index 7309b4f75a..d59ff61a94 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -14795,47 +14795,6 @@ nothingund:
blank();
}
-void DreamGenContext::checkifset() {
- STACK_CHECK;
- es = data.word(kBuffers);
- bx = (0+(228*13)+32+60+(32*32)+(11*10*3)+768+768+768+(32*32))+(127*5);
- cx = 127;
-identifyset:
- _cmp(es.byte(bx+4), 255);
- if (flags.z())
- goto notasetid;
- _cmp(al, es.byte(bx));
- if (flags.c())
- goto notasetid;
- _cmp(al, es.byte(bx+2));
- if (!flags.c())
- goto notasetid;
- _cmp(ah, es.byte(bx+1));
- if (flags.c())
- goto notasetid;
- _cmp(ah, es.byte(bx+3));
- if (!flags.c())
- goto notasetid;
- pixelcheckset();
- if (flags.z())
- goto notasetid;
- isitdescribed();
- if (flags.z())
- goto notasetid;
- al = es.byte(bx+4);
- ah = 1;
- obname();
- al = 0;
- _cmp(al, 1);
- return;
-notasetid:
- _sub(bx, 5);
- _dec(cx);
- _cmp(cx, -1);
- if (!flags.z())
- goto identifyset;
-}
-
void DreamGenContext::findpathofpoint() {
STACK_CHECK;
push(ax);
@@ -17891,7 +17850,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) {
case addr_mainscreen: mainscreen(); break;
case addr_madmanrun: madmanrun(); break;
case addr_identifyob: identifyob(); break;
- case addr_checkifset: checkifset(); break;
case addr_findpathofpoint: findpathofpoint(); break;
case addr_findfirstpath: findfirstpath(); break;
case addr_checkifpathison: checkifpathison(); break;
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index 4e5505c1ee..a27665bf37 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -113,7 +113,6 @@ public:
static const uint16 addr_checkifpathison = 0xca04;
static const uint16 addr_findfirstpath = 0xc9f0;
static const uint16 addr_findpathofpoint = 0xc9ec;
- static const uint16 addr_checkifset = 0xc9dc;
static const uint16 addr_identifyob = 0xc9d4;
static const uint16 addr_madmanrun = 0xc9cc;
static const uint16 addr_mainscreen = 0xc9c8;
@@ -1440,7 +1439,6 @@ public:
void selectslot2();
void runtap();
//void domix();
- void priesttext();
//void paneltomap();
//void obname();
void getridoftemp3();
@@ -1449,7 +1447,7 @@ public:
void runendseq();
void dumpdiarykeys();
void disablesoundint();
- void checkifset();
+ void priesttext();
//void showallex();
void openpoolboss();
void buttontwo();
@@ -1651,6 +1649,7 @@ public:
void bossman();
void getridofpit();
void convnum();
+ //void checkifset();
void nothelderror();
//void readheader();
void getsetad();
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index 5b42e37079..ff79a90088 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -1738,11 +1738,11 @@ bool DreamGenContext::compare(uint8 index, uint8 flag, const char id[4]) {
}
void DreamGenContext::isitdescribed() {
- ObjPos *pos = (ObjPos *)es.ptr(bx, sizeof(ObjPos));
+ const ObjPos *pos = (const ObjPos *)es.ptr(bx, sizeof(ObjPos));
flags._z = !isitdescribed(pos);
}
-bool DreamGenContext::isitdescribed(ObjPos *pos) {
+bool DreamGenContext::isitdescribed(const ObjPos *pos) {
uint16 offset = segRef(data.word(kSetdesc)).word(kSettextdat + pos->index * 2);
uint8 result = segRef(data.word(kSetdesc)).byte(kSettext + offset);
return result != 0;
@@ -1755,5 +1755,34 @@ bool DreamGenContext::isCD() {
// Maybe detect the version during game id?
return (data.byte(kSpeechloaded) == 1);
}
+
+void DreamGenContext::checkifset() {
+ flags._z = !checkifset(al, ah);
+}
+
+bool DreamGenContext::checkifset(uint8 x, uint8 y) {
+ const ObjPos *setList = (const ObjPos *)segRef(data.word(kBuffers)).ptr(kSetlist, sizeof(ObjPos) * 128);
+ for (size_t i = 0; i < 128; ++i) {
+ const ObjPos *pos = setList + 127 - i;
+ if (pos->index == 0xff)
+ continue;
+ if (x < pos->xMin)
+ continue;
+ if (x >= pos->xMax)
+ continue;
+ if (y < pos->yMin)
+ continue;
+ if (y >= pos->yMax)
+ continue;
+ if (! pixelcheckset(pos, x, y))
+ continue;
+ if (! isitdescribed(pos))
+ continue;
+ obname(pos->index, 1);
+ return true;
+ }
+ return false;
+}
+
} /*namespace dreamgen */
diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h
index 6cb96e9c0f..f6d57c18bf 100644
--- a/engines/dreamweb/stubs.h
+++ b/engines/dreamweb/stubs.h
@@ -217,7 +217,9 @@
void compare();
bool compare(uint8 index, uint8 flag, const char id[4]);
void pixelcheckset();
- bool pixelcheckset(ObjPos *pos, uint8 x, uint8 y);
+ bool pixelcheckset(const ObjPos *pos, uint8 x, uint8 y);
void isitdescribed();
- bool isitdescribed(ObjPos *objPos);
+ bool isitdescribed(const ObjPos *objPos);
+ void checkifset();
+ bool checkifset(uint8 x, uint8 y);
diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp
index 8d437c2c73..be3f58ce63 100644
--- a/engines/dreamweb/vgagrafx.cpp
+++ b/engines/dreamweb/vgagrafx.cpp
@@ -458,11 +458,11 @@ void DreamGenContext::transferinv() {
void DreamGenContext::pixelcheckset() {
uint8 x = al;
uint8 y = ah;
- ObjPos *pos = (ObjPos *)es.ptr(bx, sizeof(ObjPos));
+ const ObjPos *pos = (const ObjPos *)es.ptr(bx, sizeof(ObjPos));
flags._z = !pixelcheckset(pos, x, y);
}
-bool DreamGenContext::pixelcheckset(ObjPos *pos, uint8 x, uint8 y) {
+bool DreamGenContext::pixelcheckset(const ObjPos *pos, uint8 x, uint8 y) {
x -= pos->xMin;
y -= pos->yMin;
SetObject *setObject = getsetad(pos->index);