Scope Expansion and Resolution Woes

Posted: 02 Nov 2022

Discussing the expansion of Astralathe's scope and going over a couple of quality of life patches to make the game a little bit nicer with modern screen resolutions

When Astralathe began, its only real purpose was to add real modding support to Psychonauts, adding a load order system and more. That scope has expanded since & Astralathe now aims to do that but also provide fixes and patches. There’s 2 of those in particular I wanna talk about

Now, Psychonauts actually runs pretty well on modern systems! I think the version of OpenAL it uses sometimes causes audio issues (grumble grumble ISACT grumble…) but generally besides that you won’t encounter any problems playing the game on a modern PC.

However, there is one factor that seems to keep tripping it up and technically it’s not even an issue exclusive to modern systems - screen resolution. And the game’s issues with this manifest in 2 different ways (that I know of).

The first is the obvious one almost everyone knows about and that’s widescreen support. The game doesn’t support widescreen properly and when running the game in widescreen resolutions things get all stretched out which is pretty unfortunate.

The other issue is a bit more specific - the firestarting temperature gauge. Yeah. I’m gonna focus on this one first and get to the widescreen thing after because I’ve wanted to talk about this for a while and as far as I know Astralathe is the only patch right now that fixes it.

So, what’s wrong with the gauge? Well, to be specific, the bug is not just with the gauge but with a function known as ECamera::WorldCoordsToScreen. This function takes some coordinates in the game world and translates them to coordinates on the screen.

This allows you to place 2D UI elements to look as if they’re in the world. For example, making it look like the temperature gauge is above an entity’s head…

Now this actually does affect more than just that gauge, but that’s the most noticeable symptom of the issue so that was what prompted me to investigate it. The other things affected I actually had to dig for in the code and manually compare to even see them.

To be clear - this is a completely seperate issue from any widescreen problems! This issue would happen even playing on period accurate hardware on any resolution different from 640x480. It’s a port issue! 640x480 is the resolution of the game on the Xbox.

It even affects the PS2 port but it’s super minor because the difference is small… but the PS4 version of the PS2 version though has its own widescreen patch that does make it a noticeable issue. That port can’t catch a break.

I’ll talk about the cases in a moment but the gauge is the easiest to demo so here we go. First - what’s the actual issue? Well, here’s a demonstration of the original unpatched behaviour, courtesy of Ranger Ford.

That’s… unfortunate. As you can see, the more the resolution differs from 640x480, the more incorrect the function’s result is and the further out anything using this function drifts.

At the kinds of resolutions most people play this game at nowadays, this gauge sometimes just isn’t even visible on screen at all except when things are lined up just right. I wouldn’t be surprised if some people don’t even know this UI element exists!

In this case it does have a very minor effect on gameplay, since it means you also can’t see the Cougars’ gauges, but even if it doesn’t really matter it’s still a shame that things like this are an issue.

But! As it turns out the game… kinda has a fix built in? Here’s a Linux decompile of the function in question. As you can see, if param_4 is true, then the game will actually scale the result based on how much the resolution differs from 640x480!

And as it turns out so far I’ve observed that just having Astralathe forcefully make it so this parameter is always true seems to fix the issue with no ill effects. I’m not positive what use case there is to having this parameter be false, maybe I’m missing something?

Here’s a screenshot of the game running in 1280x960 with no issue!

And that debug text I mentioned before. It’s not much but still appreciated.

There’s one other thing affected by this that I wanna mention, it’s not important but it’s a fascinating detail with a bit of backstory - the journal. Running at a higher resolution, you’ve probably noticed or at least subsconsciously registered that it comes up from offscreen:

You wouldn’t actually think there’s an issue here, it looks fine and makes sense. I’d agree with you, this is probably better than the intended effect. Because if you play at the original 640x480, the journal comes out of Raz’s left hand. Strange, huh? But we know exactly why.

In early versions of the game, the journal was an inventory item! In fact here it is as seen an early build of the game known as Li-Po 553!

It’s interesting because using it immediately opens the menu, you can’t hold it like a normal item. It’s basically a long winded way of pausing, but you can also open it just using start. And when you press start, it still comes out of his hand like in the final game.

I have a theory on this - I think Li-Po 553 is in an intermediate state from some time after the journal was was proper inventory item and before it was completely deprecated. I think that once upon a time you could hold it out, and using it would open the menu.

Having the journal open out from Raz’s hand would make sense because assuming I’m right, he’d be holding it and it’d have the effect of the UI journal appearing and opening out from the one in his hand which’d be cool. I could still be wrong, though I’d be happy to be corrected.

And so this vestigial remnant remains in the final game only to be obscured on PC by a wonky function not playing nice with higher resolutions. Really fascinating stuff. Like I said, honestly I think the “broken” version looks fine though it does depend on the resolution.

That wraps up what I wanted to talk about for this issue in particular but for the next part of the thread I want to discussion the second issue in play - the game’s (lack of) widescreen support.

Well… it’s a mostly solved problem already, actually. Anyone who does a quick check will pretty quickly find the existing widescreen patch, which was created by @ThirteenAG as part of their Widescreen Fixes Pack and can be found here: https://thirteenag.github.io/wfp#psychonauts

This patch makes fixes to make running the game in widescreen a better time all around and even throws in a bonus feature that can disable the game’s auto-pause when the window loses focus.

It even works alongside Astralathe! So, what more can Astralathe possibly bring to the table when it comes to widescreen support?? Well, unfortunately there is a limit to what a regular patch can do.

No matter what you do, the game’s assets are still designed for 4:3. For fullscreen images you’re left with a dilemma - do you stretch them or do you allow them to display at 4:3 within the widescreen resolution, leaving borders and potentially making it look busted?

Neither of those are ideal and the answer to that is very situational. FMVs for example are rendered at 4:3 and there is absolutely no chance of fixing that but fortunately there’s nothing wrong with just leaving them be and allowing the sides of the screen to have black borders.

Meanwhile, some things are allowed to stretch. The loading screen background for example would probably look strange if left like this, so it fills the screen.

Unfortunately though, sooner or later you’ll start to run into cases where neither of these options is good. The prime example in the existing patch? Memory vaults.

You might already know what I mean if you’ve ever played the original Psychonauts with the widescreen patch. See, once again a decision had to be made - stretch them out or not?

The problem here is that if you stretch them out you kinda compromise the wonderful Scott C. illustrations.

If you don’t, well… you end up being able to see the other slides on the borders, and even a bit of the game in the background.

There’s not really much winning in this case. You’re faced with the choice of making it either properly fill the screen (stretching the art) or keeping it fit to 4:3 (looks broken). It’s down to preference and the better option is subjective.

I do personally think that the patch made the right decision of keeping the integrity of the art intact but maybe you disagree. Either way, it’s an unfortunate situation.

Right, so that’s the problem. What can Astralathe possibly do? Didn’t I just say that these are the only two choices?

Well, these problems arise because the original game’s assets are built for 4:3. To conjure a better solution to this issue you’d need to swap them out with new ones adapted to work with widescreen.

And remember what I said at the start? Astralathe is a modding framework. It was specifically built to provide a means to cleanly override the game’s assets. With an Astralathe-integrated widescreen patch, we can do more.

And so with ThirteenAG graciously giving me permission to fully integrate their existing widescreen patch into Astralathe, providing a solid base for widescreen support, I set out to build a solution.

The only real condition for integrating their patch is that I contribute any relevant changes back into the original standalone patch. Unfortunately any fixes relying on file overrides can’t be merged but I can still do what I can: https://github.com/ThirteenAG/WidescreenFixesPack/pull/1171

So, with a bit of effort in an image editor and a couple quick hacks in Astralathe’s code…

There it is. No stretching. No buggy borders. Fully functional widescreen in a memory vault.

And so, here’s our final comparison. Really great stuff.

So, that’s the plan. Right now it’s just the memory vaults that I’ve applied this to but those were the main, most noticeable problem spot.

Another place where this issue is most prominent is in the Lungfish Lair. This overlay doesn’t fit the screen properly. You probably could stretch it and it’d look fine but honestly I’m not even sure yet how to do that.

I will be honest - I do not fully understand how the original patch works in some places, I’m still figuring it out. Something tricky about this overlay in particular is that it’s set up from a Lua script which complicates things a little.

But, all that aside, I think this is all doable and even without these extra fixes it’s great having the widescreen fix built directly into Astralathe for convenience. Given the chance I hope I can include more patches like this and the WorldToScreen fix in the future.