Skip to content

Commit

Permalink
DREAMWEB: Clean up loop
Browse files Browse the repository at this point in the history
  • Loading branch information
wjp committed Nov 19, 2011
1 parent 049a0c2 commit 90ecc19
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions engines/dreamweb/print.cpp
Expand Up @@ -246,18 +246,23 @@ const char *DreamGenContext::monprint(const char *string) {
uint16 x = data.word(kMonadx);
Frame *tempCharset = (Frame *)segRef(data.word(kTempcharset)).ptr(0, 0);
const char *iterator = string;
while (true) {
bool done = false;
while (!done) {

uint16 count = getnumber(tempCharset, (const uint8 *)iterator, 166, false, &x);
do {
do {
char c = *iterator++;
if (c == ':')
break;
if ((c == 0) || (c == 34) || (c == '='))
goto finishmon;
if ((c == 0) || (c == '"') || (c == '=')) {
done = true;
break;
}
if (c == '%') {
data.byte(kLasttrigger) = *iterator;
iterator += 2;
goto finishmon;
done = true;
break;
}
c = engine->modifyChar(c);
printchar(tempCharset, &x, data.word(kMonady), c, 0, NULL, NULL);
Expand All @@ -268,16 +273,13 @@ const char *DreamGenContext::monprint(const char *string) {
vsync();
lockmon();
delcurs();
--count;
}
while(count);
} while (--count);

x = data.word(kMonadx);
scrollmonitor();
data.word(kCurslocx) = data.word(kMonadx);
}
finishmon:
data.word(kCurslocx) = data.word(kMonadx);
scrollmonitor();

data.byte(kKerning) = 0;
return iterator;
}
Expand Down

2 comments on commit 90ecc19

@tramboi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't like gotos, do you? :)
I quite prefer them for exiting two loops without the overhead of retesting a bool for nothing.

@wjp
Copy link
Contributor Author

@wjp wjp commented on 90ecc19 Nov 19, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't, no. :-)

Note that this also removes the duplicate kCurslocx/scrollmonitor code. (I checked the order isn't important, by the way.)

Please sign in to comment.