Week 6 – Working on PINK

Picking up from where I left last week, I decided to go with PINK as the next engine to work on. For those who don’t know about it, it’s the engine used by two Pink Panther games, The Pink Panther: Passport to Peril and Pink Panther: Hokus Pokus Pink.

The main issue with the engine is that it relies on ScummVM’s graphics backend MacGUI which has been updated since the engine was finished. This broke some of the functionality and introduced various bugs. My task is to identify and resolve all of these bugs. In this blog I’ll go over some of the bugs I resolved.

The first bug I had some trouble with was these transparency artifacts in the sub menu.

Top Right and Bottom Left have “green dots”

This one took me a lot of time simply because I had no idea of how things were rendered. A lot of time was spent just going through the macgui code to understand what was even happening. However what I learned helped in all subsequent fixes so it was time well spent.

In macgui, green is used as a transparency color. The sub menu would be drawn on a green background and then all the non-green pixels would be moved to the final screen. Originally the menu bar and the submenu were drawn together, after which there was one step of copying the non-green pixels to a screen. During one of the refactors, the rendering of menubar and submenu were split into two different functions. However the function which would copy only the non-green pixels was left out of the submenu rendering. That’s what caused the bug and as you might think, the fix was just to add that function back and that’s what I did.

No more green dots

Next would be the missing text in the PDA for Passport to Peril.

The black box is supposed to have yellow text

After some debugging I realized that the text is there but black colored which means the problem is related to setting the font color. Looking into the code, the colored font was applied to the string but then the function which appends the string to the textbox was still using the older plain string. Quite easy to fix.

Wait that’s not yellow…

Well this uncovered another bug, this time with the color which was being applied to the font. So what happened originally was that PINK’s code read a value which was a color stored as BGR and used macros to extract the individual colors which was then used to find the closest color in the palette. The id of that color would then be used in PINK’s code itself to color the text.

However after some refactors, the place where the text would be colored moved to macgui and whoever made the changes just used the BGR color value for the font. Unfortunately the value was stored as _textRGB so they didn’t realize that the colors weren’t in the correct order. If we look at the hex color code, yellow is 0xFFFF00 and cyan is 0x00FFFF which matches with what we are currently seeing. The background color might be suffering from the same problem but coincidently the only background colors used are black (0x000000), green (0x00FF00) and white (0xFFFFFF). All three are unaffected by this issue :P. Anyways the fix for this was simple and all I did was to store the color as RGB.

Yellow finally!

The final bug I would like to talk about was extremely simple to fix and was only complicated by an initial misunderstanding. So there were these two separate bugs I had identified.

The title text should be center aligned
Another transparency artifact?

I started with the misaligned text and even after spending a long time, I could find no problem with the alignment code. I even calculated the correct alignment offsets by hand and sure enough the values matched. I then decided to move on to a different task for the time being and tried to figure out why there was an out of place green rectangle.

This is when I realized that maybe it’s actually a part of the textbox and the entire textbox itself is misaligned. I checked the part which render the textbox and it was just like that. The textbox was also being rendered at an offset which wasn’t required because we were also doing it for the text. I removed the offset for the textbox and that fixed both of the issues.

I fixed some other issues too but none of them were as interesting as these. As for the progress, as of writing this only two more bugs remain to be fixed. After that I plan on going over the game to see if anything else comes up. If that goes fine then I can continue on to the next engine WAGE but that’s something for the next blog post.

Thanks for reading!

2 replies on “Week 6 – Working on PINK”

Nice work. Maybe should’ve mentioned that the screen redraw got fixed, but oh well, can’t list all minor bugs.

Before you consider the engine complete, take a careful look at the actual behavior of the menu commands, some are rather poorly stubbed. And the menu is actually supposed to be partially dynamically generated, listing the last ten or so save games.

Yeah I didn’t list everything which was fixed, mostly because there really wasn’t much to talk about other than “I just added a line here and it worked”.

And thanks for bringing up menu, I was actually looking into it to see if I could finish it before the blog but like you said, it’s a decent amount of work so I had to leave it for later. It is indeed on my radar and I’ll try to fix it this week.

Leave a Reply to Henke37 Cancel reply

Your email address will not be published. Required fields are marked *