aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2011-06-16 16:43:48 +0200
committerWillem Jan Palenstijn2011-06-16 16:43:48 +0200
commitae67a9a958e26a237ddb7910f6c4a1b6b088dc77 (patch)
tree6141a87a2d78901a61a5e5ad98aac390307ca40f
parent2c76a4af40fdafecd5191c55b3d54b204022c13b (diff)
downloadscummvm-rg350-ae67a9a958e26a237ddb7910f6c4a1b6b088dc77.tar.gz
scummvm-rg350-ae67a9a958e26a237ddb7910f6c4a1b6b088dc77.tar.bz2
scummvm-rg350-ae67a9a958e26a237ddb7910f6c4a1b6b088dc77.zip
DREAMWEB: Re-optimize unbounded code blocks
This gets rid of some unused labels. We need to be careful not be optimize too much, as that could remove the very label the unbounded block was added for.
-rw-r--r--devtools/tasmrecover/tasm/cpp.py2
-rw-r--r--devtools/tasmrecover/tasm/proc.py4
-rw-r--r--engines/dreamweb/dreamgen.cpp12
3 files changed, 5 insertions, 13 deletions
diff --git a/devtools/tasmrecover/tasm/cpp.py b/devtools/tasmrecover/tasm/cpp.py
index 5d460961a6..da21efe21d 100644
--- a/devtools/tasmrecover/tasm/cpp.py
+++ b/devtools/tasmrecover/tasm/cpp.py
@@ -483,6 +483,8 @@ namespace %s {
self.proc.stmts.append(s)
self.proc.add("ret")
print "skipping %d instructions, todo: %d" %(start, len(self.proc.stmts) - start)
+ print "re-optimizing..."
+ self.proc.optimize(keep_labels=[label])
self.proc.visit(self, start)
self.body += "}\n";
self.translated.insert(0, self.body)
diff --git a/devtools/tasmrecover/tasm/proc.py b/devtools/tasmrecover/tasm/proc.py
index e5af1afae5..6db3b7a682 100644
--- a/devtools/tasmrecover/tasm/proc.py
+++ b/devtools/tasmrecover/tasm/proc.py
@@ -66,7 +66,7 @@ class proc:
i += 1
return
- def optimize(self):
+ def optimize(self, keep_labels=[]):
print "optimizing..."
#trivial simplifications
while len(self.stmts) and isinstance(self.stmts[-1], op.label):
@@ -109,7 +109,7 @@ class proc:
if not isinstance(s, op.label):
continue
print "checking label %s..." %s.name
- used = False
+ used = s.name in keep_labels
if s.name not in self.retlabels:
for j in self.stmts:
if isinstance(j, op.basejmp) and j.label == s.name:
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index 1d079d9571..7ad10a2e42 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -3984,11 +3984,8 @@ atlast2:
context.ds.byte(context.di+17) = context.al;
context._cmp(context.cl, 5);
if (!context.flags.z())
- goto notnearly;
+ return /* (notnearly) */;
context.data.byte(kThroughdoor) = 0;
-notnearly:
- return;
- return;
}
void updatepeople(Context &context) {
@@ -7343,12 +7340,6 @@ iswatching:
justgetback:
context.data.byte(kInvopen) = 0;
context.data.byte(kOpenedob) = 255;
- return;
-examlist:
-invlist1:
-openchangesize:
-withlist1:
- return;
}
void setpickup(Context &context) {
@@ -13731,7 +13722,6 @@ axeondoor:
context.data.byte(kWatchspeed) = 1;
context.data.byte(kSpeedcount) = 1;
context.data.byte(kGetback) = 1;
- return;
}
void useelvdoor(Context &context) {