aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorBertrand Augereau2011-08-11 23:13:17 +0200
committerBertrand Augereau2011-08-15 22:30:16 +0200
commite78a5a2b08012dfe786da6d77abcc052436ace9c (patch)
tree0547d76cd24b9d60d50de5968ffa604bce11eb0e /engines
parent01ccadf7c12a2675ced62ec6f89873bf821b4c6a (diff)
downloadscummvm-rg350-e78a5a2b08012dfe786da6d77abcc052436ace9c.tar.gz
scummvm-rg350-e78a5a2b08012dfe786da6d77abcc052436ace9c.tar.bz2
scummvm-rg350-e78a5a2b08012dfe786da6d77abcc052436ace9c.zip
DREAMWEB: 'checkifperson' ported to C++
Diffstat (limited to 'engines')
-rw-r--r--engines/dreamweb/dreamgen.cpp64
-rw-r--r--engines/dreamweb/dreamgen.h11
-rw-r--r--engines/dreamweb/sprite.cpp12
-rw-r--r--engines/dreamweb/structs.h13
-rw-r--r--engines/dreamweb/stubs.cpp36
-rw-r--r--engines/dreamweb/stubs.h4
6 files changed, 61 insertions, 79 deletions
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index 2964d6fdf0..0fdc75be99 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -16339,69 +16339,6 @@ nothingund:
blank();
}
-void DreamGenContext::checkifperson() {
- STACK_CHECK;
- es = data.word(kBuffers);
- bx = (0+(228*13)+32+60+(32*32)+(11*10*3)+768+768+768+(32*32)+(128*5)+(80*5)+(100*5));
- cx = 12;
-identifyreel:
- push(cx);
- _cmp(es.byte(bx+4), 255);
- if (flags.z())
- goto notareelid;
- push(es);
- push(bx);
- push(ax);
- ax = es.word(bx+0);
- data.word(kReelpointer) = ax;
- getreelstart();
- _cmp(es.word(si+2), 0x0ffff);
- if (!flags.z())
- goto notblankpers;
- _add(si, 5);
-notblankpers:
- cx = es.word(si+2);
- ax = es.word(si+0);
- push(cx);
- getreelframeax();
- cx = pop();
- _add(cl, es.byte(bx+4));
- _add(ch, es.byte(bx+5));
- dx = cx;
- _add(dl, es.byte(bx+0));
- _add(dh, es.byte(bx+1));
- ax = pop();
- bx = pop();
- es = pop();
- _cmp(al, cl);
- if (flags.c())
- goto notareelid;
- _cmp(ah, ch);
- if (flags.c())
- goto notareelid;
- _cmp(al, dl);
- if (!flags.c())
- goto notareelid;
- _cmp(ah, dh);
- if (!flags.c())
- goto notareelid;
- cx = pop();
- ax = es.word(bx+2);
- data.word(kPersondata) = ax;
- al = es.byte(bx+4);
- ah = 5;
- obname();
- al = 0;
- _cmp(al, 1);
- return;
-notareelid:
- cx = pop();
- _add(bx, 5);
- _dec(cx);
- if (!flags.z())
- goto identifyreel;
-}
-
void DreamGenContext::checkifset() {
STACK_CHECK;
es = data.word(kBuffers);
@@ -19949,7 +19886,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) {
case addr_madmanrun: madmanrun(); break;
case addr_checkcoords: checkcoords(); break;
case addr_identifyob: identifyob(); break;
- case addr_checkifperson: checkifperson(); break;
case addr_checkifset: checkifset(); break;
case addr_checkifex: checkifex(); break;
case addr_checkiffree: checkiffree(); break;
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index b5f6a5fc3c..f3a2a3090e 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -146,7 +146,6 @@ public:
static const uint16 addr_checkiffree = 0xc9e4;
static const uint16 addr_checkifex = 0xc9e0;
static const uint16 addr_checkifset = 0xc9dc;
- static const uint16 addr_checkifperson = 0xc9d8;
static const uint16 addr_identifyob = 0xc9d4;
static const uint16 addr_checkcoords = 0xc9d0;
static const uint16 addr_madmanrun = 0xc9cc;
@@ -1362,7 +1361,7 @@ public:
void clearendpal();
void findtext1();
void isryanholding();
- void interupttest();
+ void showslots();
void usecashcard();
void usewall();
void opentomb();
@@ -1494,9 +1493,10 @@ public:
void isitdescribed();
void hotelbell();
void loadspeech();
+ void interupttest();
//void cls();
//void printsprites();
- //void dumptimedtext();
+ //void checkifperson();
void showallobs();
//void getnumber();
void adjustleft();
@@ -1564,7 +1564,7 @@ public:
void folderhints();
void openhoteldoor();
void removesetobject();
- void checkifperson();
+ //void dumptimedtext();
//void frameoutfx();
void blank();
void drinker();
@@ -1749,10 +1749,9 @@ public:
void loadintotemp2();
void gamer();
void personnametext();
- void quitsymbol();
void readfromfile();
void initialinv();
- void showslots();
+ void quitsymbol();
//void modifychar();
void hangon();
void settopright();
diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp
index be74be6c5f..0e69607295 100644
--- a/engines/dreamweb/sprite.cpp
+++ b/engines/dreamweb/sprite.cpp
@@ -570,14 +570,10 @@ void DreamGenContext::showgamereel() {
es.word(bx+3) = data.word(kReelpointer);
}
-void DreamGenContext::getreelframeax() {
- push(ds);
- data.word(kCurrentframe) = ax;
- findsource();
- es = ds;
- ds = pop();
- cx = (data.word(kCurrentframe) - data.word(kTakeoff)) * 2;
- bx = (data.word(kCurrentframe) - data.word(kTakeoff)) * 6;
+const Frame *DreamGenContext::getreelframeax(uint16 frame) {
+ data.word(kCurrentframe) = frame;
+ uint16 offset = data.word(kCurrentframe) - data.word(kTakeoff);
+ return findsourceCPP() + offset;
}
void DreamGenContext::showrain() {
diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h
index 48b3f914d0..775466ad18 100644
--- a/engines/dreamweb/structs.h
+++ b/engines/dreamweb/structs.h
@@ -96,6 +96,19 @@ struct Reel {
uint8 b4;
};
+struct People {
+ uint8 b0;
+ uint8 b1;
+ uint16 w0() const { return READ_LE_UINT16(&b0); }
+ void setW0(uint16 v) { WRITE_LE_UINT16(&b0, v); }
+ uint8 b2;
+ uint8 b3;
+ uint16 w2() const { return READ_LE_UINT16(&b2); }
+ void setW2(uint16 v) { WRITE_LE_UINT16(&b2, v); }
+ uint8 b4;
+
+};
+
struct Room {
uint8 name[10];
uint8 b10;
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index 0a28073158..5f0ed98447 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -964,4 +964,40 @@ void DreamGenContext::checkdest(const uint8 *roomsPaths) {
data.byte(kDestination) = destination;
}
+void DreamGenContext::checkifperson() {
+ flags._z = not checkifperson(al, ah);
+}
+
+bool DreamGenContext::checkifperson(uint8 x, uint8 y) {
+ People *people = (People *)segRef(data.word(kBuffers)).ptr(kPeoplelist, 0);
+
+ for (size_t i = 0; i < 12; ++i, ++people) {
+ if (people->b4 == 255)
+ continue;
+ data.word(kReelpointer) = people->w0();
+ Reel *reel = getreelstartCPP();
+ if (reel->frame() == 0xffff)
+ ++reel;
+ const Frame *frame = getreelframeax(reel->frame());
+ uint8 xmin = reel->x + frame->x;
+ uint8 ymin = reel->y + frame->y;
+ uint8 xmax = xmin + frame->width;
+ uint8 ymax = ymin + frame->height;
+ if (x < xmin)
+ continue;
+ if (y < ymin)
+ continue;
+ if (x >= xmax)
+ continue;
+ if (y >= ymax)
+ continue;
+ data.word(kPersondata) = people->w2();
+ al = people->b4;
+ ah = 5;
+ obname();
+ return true;
+ }
+ return false;
+}
+
} /*namespace dreamgen */
diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h
index 79f71ba8c8..395eac6081 100644
--- a/engines/dreamweb/stubs.h
+++ b/engines/dreamweb/stubs.h
@@ -101,7 +101,7 @@
void showgamereel();
void showreelframe();
void showreelframe(Reel *reel);
- void getreelframeax();
+ const Frame *getreelframeax(uint16 frame);
void turnpathonCPP(uint8 param);
void turnpathoffCPP(uint8 param);
void getroomspaths();
@@ -119,4 +119,6 @@
void showrain();
void deltextline();
void doblocks();
+ void checkifperson();
+ bool checkifperson(uint8 x, uint8 y);