10 days later

I left the last blogpost with an image of a video from J.U.L.I.A. being played inside ScummVM, but that image still didn’t have the clearing of the screen included, so to start of this post, here is how it currently looks:

The J.U.L.I.A.-demo intro
That improvement did however exist at the time I posted that last blogpost, so let’s get on with what has improved since then:

TTF-Rendering looks better

Last time I posted a screenshot of the TTF-rendering that looked like this:
How fonts looked last week

Notice that the text is impossible to read, as well as being quite small. There was also an issue with the size of each line making the “descending” parts of characters cut off on the lowest lines. Thanks to a bit of help from LordHoto, I managed to find out that I had been stupid, and used the wrong variables for creating the drawing-surface for the fonts, I had used the font height that the scripts ask for, while in reality I should have used the font height that the TTF-loader in ScummVM returns (which is the height from the lowest point to the highest point, instead of the height from the baseline to the highest point).

While looking through the code to find out why this happened, I took this screenshot, which shows red lines at the points I was asking the TTF-font to render each line:

Why using the wrong height looks wrong.

The fonts were also drawn about too small, as WME used a dpi that was 4/3 of what ScummVM uses in it’s TTF-code (96 vs 72), simply multiplying the font-size specified by the scripts made the font a lot better, although, there were still some issues relating to the “layering” that WME does to get the shadowed-fonts it has. As it turns out, this was done by drawing the same line multiple times with different colour-values, at differing offsets. The current draw-code did something rather silly when it got offsets (well, it simply changed the left and top parts of the rect that specifies the draw-area, without making sure the width stayed the same, making it an odd skew-and-scale-operation). Fixing that as well provided the following result:

Font-drawing after fixing offsets and sizing.

Making sure we even bother to use the text alignment the scripts ask for, as well as mostly the right colours, provides quite an improvement for Dirty Split too, compare last posts font-rendering:

Last week’s rendering

To this weeks version of the exact same scene:

This weeks rendering
It’s not perfect, as the text should be a bit lighter, but it’s getting there atleast.

String-concatenation works again:

… and I didn’t even know I broke it, well, turns out I must have replaced some variable-names in the II_ADD-script-function, and forgot to make sure everything was changed correctly, which made concatenation of strings always return NULL instead of what it was supposed to return, thus making things like SetImage completely broken, putting that right again, provided one of the biggest leaps of functionality I’ve seen in a while:

What difference one single variable-name can have.

Notice that the images on the buttons are in place now in the above picture.

Entity-videos now work too

I forgot that I had to add a few bits and pieces to AdEntity too, to get the videos working for non-fullscreen scenes like this one:

Waking up all alone in the middle of nowhere, literally.

Those little videos also use alpha-masks to allow for non-rectangular videos, in this case, the face in the upper right corner has such a mask to hide the parts that would otherwise fit in the rectangular box it’s being played in:

Alpha-masked video

Note though that the current solution for applying alpha-masks is both ugly, and non-endian safe, and was mostly put in to make sure things looked right, I will be cleaning this up in the coming weeks.

As a final comparison: Look at this picture from last week:

Last week’s “Enter manual override”

Now compare that to:

This week’s version of the same scene
In the upper picture you can see the rectangular box that the videos are being played in, that is hidden by the alpha masking now. Also note the difference in the menu-buttons, and the alignment and presentation of the text. You’d almost think that the demo was completable now…

And it is:

After fixing all of the above, and getting rid of a few hundred megabytes of memory leaks, the game still hung when going down to the planet, so I started looking, and it turns out that the string-splitter function had a bug that caused it to never move on from the first token, but simply continued to push that token to it’s result-list, thus eating up a few gigabytes in a matter of seconds. Replacing the STL-string-like solution with ScummVM’s Common::StringTokenizer, fixed the issue, and allowed me to complete the planet-side mission, thus letting me complete the last two puzzles.
The last puzzle in the J.U.L.I.A.-demo running in ScummVM

In the tradition of showing something that DOESN’T work as a closing-point, here’s a picture of how J.U.L.I.A. looks when closing the game during the tutorial…