From ae67a9a958e26a237ddb7910f6c4a1b6b088dc77 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Thu, 16 Jun 2011 16:43:48 +0200 Subject: 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. --- devtools/tasmrecover/tasm/cpp.py | 2 ++ devtools/tasmrecover/tasm/proc.py | 4 ++-- engines/dreamweb/dreamgen.cpp | 12 +----------- 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) { -- cgit v1.2.3