[Scummvm-devel] Recent change to the Broken Sword 1 cutscene player

Torbjörn Andersson eriktorbjorn at telia.com
Tue Nov 18 20:09:23 CET 2008


Hi,

I recently made a slight change to the way Broken Sword 1's cutscene
player draws subtitles. Before, it would make a copy of the part of the
frame where the subtitles were to be drawn, draw the subtitles in that
buffer, and then copyRectToScreen() it. This was awkward, because
sometimes the subtitles are drawn partially or even entirely outside
where the frame is. Now I'm using the lockScreen() / unlockScreen() API
instead.

This is much more elegant in this case. Each subtitle is basically
turned into a transparent image, which is drawn to the screen. But
copyRectToScreen() doesn't handle transparency, so it had to copy part
of the frame to the image before drawing the subtitle. And the subtitles
are sometimes partially, or even entirely outside the frame.

The downside is that now it forces the backend to update the entire
screen for each frame.

So my question is: Does this cause unacceptable performance regressions
for any of the ScummVM ports? If so, this would be an excellent time to
say so. Fingolfin raised that possibility back when he first proposed
the lockScreen() / unlockScreen() API:

> One obvious issue here is that dirty rect handling is harder/
> impossible, since the backend only knows that the framebuffer was
> modified, but not which parts. This could either be mitigated by an
> additional API like
>    Surface *getScreenSubsection(Rect r)
> which returns a surface for only a subsection of the screen -- so in
> a way we are re-introducing dirty rects through the backdoor (though
> the backend is free to ignore this "hinting"; also note that this
> method would have a default implementation that simply calls
> getScreenSurface).

"Wait a minute!" I hear someone ask. "The Broken Sword 1 cutscenes don't
have any subtitles!" Quite right. But there's an undocumented feature in
ScummVM that allows you to add them. Simply (actually, slowly and
tediously) add a text file for each cutscene, e.g. intro.txt. Each line
is either a comment, or two numbers (start and end frame) followed by a
text. Like so:

45 110 Paris in the fall. The last months of the year, and the end of
the millennium.
# TODO: Need to find the character code for an accented E here.
120 200 The city holds many memories for me: Of cafes, of music, of love...
201 230 ...and of death.

Torbjörn Andersson




More information about the Scummvm-devel mailing list