aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/dreamweb/stubs.cpp33
-rw-r--r--engines/dreamweb/stubs.h1
2 files changed, 33 insertions, 1 deletions
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index 4dc4ef83c7..dc05e455ff 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -817,7 +817,7 @@ void DreamGenContext::mainmanCPP(Sprite* sprite) {
}
sprite->b22 = 0;
if (data.byte(kTurntoface) != data.byte(kFacing)) {
- aboutturn();
+ aboutturn(sprite);
} else {
if ((data.byte(kTurndirection) != 0) && (data.byte(kLinepointer) == 254)) {
data.byte(kReasseschanges) = 1;
@@ -887,6 +887,37 @@ void DreamGenContext::walking() {
es = pop();
}
+void DreamGenContext::aboutturn(Sprite* sprite) {
+ if (data.byte(kTurndirection) == 1)
+ goto incdir;
+ else if ((int8)data.byte(kTurndirection) == -1)
+ goto decdir;
+ else {
+ if (data.byte(kFacing) < data.byte(kTurntoface)) {
+ uint8 delta = data.byte(kTurntoface) - data.byte(kFacing);
+ if (delta >= 4)
+ goto decdir;
+ else
+ goto incdir;
+ } else {
+ uint8 delta = data.byte(kFacing) - data.byte(kTurntoface);
+ if (delta >= 4)
+ goto incdir;
+ else
+ goto decdir;
+ }
+ }
+incdir:
+ data.byte(kTurndirection) = 1;
+ data.byte(kFacing) = (data.byte(kFacing) + 1) & 7;
+ sprite->b29 = 0;
+ return;
+decdir:
+ data.byte(kTurndirection) = -1;
+ data.byte(kFacing) = (data.byte(kFacing) - 1) & 7;
+ sprite->b29 = 0;
+}
+
void DreamGenContext::backobject(Sprite* sprite) {
push(es);
push(ds);
diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h
index d1eb5aae9f..63a898acc9 100644
--- a/engines/dreamweb/stubs.h
+++ b/engines/dreamweb/stubs.h
@@ -28,6 +28,7 @@
void initman();
void mainmanCPP(Sprite* sprite);
void walking();
+ void aboutturn(Sprite* sprite);
void backobject(Sprite* sprite);
void constant(Sprite* sprite, ObjData* objData);
void steady(Sprite* sprite, ObjData* objData);