aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorBertrand Augereau2011-08-20 12:26:10 +0200
committerBertrand Augereau2011-08-20 12:26:10 +0200
commit6cab258032b72054f901d4a19a85ac6ef8ef4513 (patch)
tree3486115ea1df70c343fdd67b513fa4cf24929200 /engines
parenteaa342fdd88227e71ee95551a064f95df3eb0dd6 (diff)
downloadscummvm-rg350-6cab258032b72054f901d4a19a85ac6ef8ef4513.tar.gz
scummvm-rg350-6cab258032b72054f901d4a19a85ac6ef8ef4513.tar.bz2
scummvm-rg350-6cab258032b72054f901d4a19a85ac6ef8ef4513.zip
DREAMWEB: Ported 'dochange' to C++
Diffstat (limited to 'engines')
-rw-r--r--engines/dreamweb/dreamgen.cpp43
-rw-r--r--engines/dreamweb/dreamgen.h3
-rw-r--r--engines/dreamweb/structs.h25
-rw-r--r--engines/dreamweb/stubs.cpp51
-rw-r--r--engines/dreamweb/stubs.h6
5 files changed, 64 insertions, 64 deletions
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index 541a938c19..0b3e57f11d 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -11338,48 +11338,6 @@ void DreamGenContext::switchryanoff() {
data.byte(kRyanon) = 1;
}
-void DreamGenContext::dochange() {
- STACK_CHECK;
- _cmp(ch, 0);
- if (flags.z())
- goto object;
- _cmp(ch, 1);
- if (flags.z())
- goto freeobject;
- push(cx);
- ah = 0;
- _add(ax, ax);
- _add(ax, ax);
- _add(ax, ax);
- push(ax);
- al = ch;
- _sub(al, 100);
- ah = 0;
- cx = 144;
- _mul(cx);
- bx = pop();
- _add(bx, ax);
- _add(bx, (0));
- es = data.word(kReels);
- cx = pop();
- es.byte(bx+6) = cl;
- return;
-object:
- push(cx);
- getsetad();
- cx = pop();
- es.byte(bx+58) = cl;
- return;
-freeobject:
- push(cx);
- getfreead();
- cx = pop();
- _cmp(es.byte(bx+2), 255);
- if (!flags.z())
- return /* (beenpickedup) */;
- es.byte(bx+2) = cl;
-}
-
void DreamGenContext::autoappear() {
STACK_CHECK;
_cmp(data.byte(kLocation), 32);
@@ -18670,7 +18628,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) {
case addr_removefreeobject: removefreeobject(); break;
case addr_switchryanon: switchryanon(); break;
case addr_switchryanoff: switchryanoff(); break;
- case addr_dochange: dochange(); break;
case addr_autoappear: autoappear(); break;
case addr_setuptimeduse: setuptimeduse(); break;
case addr_edenscdplayer: edenscdplayer(); break;
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index 8f14cbddfb..7756a58c93 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -303,7 +303,6 @@ public:
static const uint16 addr_edenscdplayer = 0xc728;
static const uint16 addr_setuptimeduse = 0xc71c;
static const uint16 addr_autoappear = 0xc70c;
- static const uint16 addr_dochange = 0xc708;
static const uint16 addr_switchryanoff = 0xc700;
static const uint16 addr_switchryanon = 0xc6fc;
static const uint16 addr_removefreeobject = 0xc6f4;
@@ -1389,7 +1388,7 @@ public:
void buttonfour();
void animpointer();
//void lockmon();
- void dochange();
+ //void dochange();
void getanyaddir();
void showsaveops();
void intromonks1();
diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h
index 8b8e1153e5..e47256186d 100644
--- a/engines/dreamweb/structs.h
+++ b/engines/dreamweb/structs.h
@@ -105,6 +105,25 @@ struct ObjData {
uint8 b63;
};
+struct FreeObject {
+ uint8 b0;
+ uint8 b1;
+ uint8 b2;
+ uint8 b3;
+ uint8 b4;
+ uint8 b5;
+ uint8 b6;
+ uint8 b7;
+ uint8 b8;
+ uint8 b9;
+ uint8 b10;
+ uint8 b11;
+ uint8 b12;
+ uint8 b13;
+ uint8 b14;
+ uint8 b15;
+};
+
struct ObjPos {
uint8 xMin;
uint8 yMin;
@@ -195,10 +214,10 @@ struct Rain {
};
struct Change {
- uint8 b0;
+ uint8 index;
uint8 location;
- uint8 b2;
- uint8 b3;
+ uint8 value;
+ uint8 type;
};
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index 0adb11e3a1..39c6e14b1f 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -1048,18 +1048,18 @@ void DreamGenContext::findormake() {
findormake(b0, b2, b3);
}
-void DreamGenContext::findormake(uint8 b0, uint8 b2, uint8 b3) {
+void DreamGenContext::findormake(uint8 index, uint8 value, uint8 type) {
Change *change = (Change *)segRef(data.word(kBuffers)).ptr(kListofchanges, sizeof(Change));
while (true) {
- if (change->b0 == 0xff) {
- change->b0 = b0;
+ if (change->index == 0xff) {
+ change->index = index;
change->location = data.byte(kReallocation);
- change->b2 = b2;
- change->b3 = b3;
+ change->value = value;
+ change->type = type;
return;
}
- if ((b0 == change->b0) && (data.byte(kReallocation) == change->location) && (b3 == change->b3)) {
- change->b2 = b2;
+ if ((index == change->index) && (data.byte(kReallocation) == change->location) && (type == change->type)) {
+ change->value = value;
return;
}
++change;
@@ -1068,18 +1068,39 @@ void DreamGenContext::findormake(uint8 b0, uint8 b2, uint8 b3) {
void DreamGenContext::setallchanges() {
Change *change = (Change *)segRef(data.word(kBuffers)).ptr(kListofchanges, sizeof(Change));
- while (change->b0 != 0xff) {
- if (change->location == data.byte(kReallocation)) {
- al = change->b0;
- ah = change->location;
- cl = change->b2;
- ch = change->b3;
- dochange();
- }
+ while (change->index != 0xff) {
+ if (change->location == data.byte(kReallocation))
+ dochange(change->index, change->value, change->type);
++change;
}
}
+FreeObject *DreamGenContext::getfreead(uint8 index) {
+ return (FreeObject *)segRef(data.word(kFreedat)).ptr(0, 0) + index;
+}
+
+ObjData *DreamGenContext::getsetad(uint8 index) {
+ return (ObjData *)segRef(data.word(kSetdat)).ptr(0, 0) + index;
+}
+
+void DreamGenContext::dochange() {
+ dochange(al, cl, ch);
+}
+
+void DreamGenContext::dochange(uint8 index, uint8 value, uint8 type) {
+ if (type == 0) { //object
+ getsetad(index)->b58[0] = value;
+ } else if (type == 1) { //freeobject
+ FreeObject *freeObject = getfreead(index);
+ if (freeObject->b2 == 0xff)
+ freeObject->b2 = value;
+ } else { //path
+ bx = kPathdata + (type - 100) * 144 + index * 8;
+ es = data.word(kReels);
+ es.byte(bx+6) = value;
+ }
+}
+
bool DreamGenContext::isCD() {
// The original sources has two codepaths depending if the game is 'if cd' or not
// This is a hack to guess which version to use with the assumption that if we have a cd version
diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h
index 53d6458fb4..6d18ce4902 100644
--- a/engines/dreamweb/stubs.h
+++ b/engines/dreamweb/stubs.h
@@ -150,7 +150,11 @@
void personnametext();
void findxyfrompath();
void findormake();
- void findormake(uint8 b0, uint8 b2, uint8 b3);
+ void findormake(uint8 index, uint8 value, uint8 type);
+ FreeObject *getfreead(uint8 index);
+ ObjData *getsetad(uint8 index);
void setallchanges();
+ void dochange();
+ void dochange(uint8 index, uint8 value, uint8 type);
bool isCD();