Categories
Experience Fun

GSoC’ 23: It’s a wrap!

Greetings, as you might have already guessed, this is the last blog post for this beautiful journey of GSoC’23, These last 3 months were amazing, and I would like to wrap it up by writing this final report!

My Introduction

I am Harishankar Kumar, a final-year student (at the time of writing), and working past three months on adding more support to the Director Engine, ScummVM implements a kind of Virtual Machines to support numerous engines, In these many engines the one which I was also working to add more support is called Macromedia Director

My work was to implement support for game titles like “Total Distortion”, “Journeyman Project”, “Meet Mediaband”, Now the thing was that ScummVM was already capable of running these titles however there were bugs and glitches which needed to be fixed before labeling these title as compatible!

What’s been done

According to the proposal, “total-distortion” right now is playable, a lot of work has been put into it and many bugs have been fixed. “meet-mediaband” has also progressed quite further due to adding UnDo Me, This in total added fixed lot of bugs, reimplemented core of Director engine and progressed it closer to what the original engine was like!

What’s left

In general, no amount of progress is ever sufficient as new bugs keep popping up, regressions that needs to be fixed, etc! But in my tenure what’s left to do:

  • Total Distortion is yet to be fully playable, many small bugs are yet to be fixed and the end needs to be tested thoroughly
  • Much work is left for meet-mediaband as well
  • Journey Man Project is almost untouched

My work

In short, all my work can be summarized by these blog posts and the PR’s attached with them:

29th May – 31st May

Implementing Mac Styled PopupMenu’s, First PR After GSoC Accepted!

PR Merged – #5005 #5056 #5059

1st June – 30th June

I am a Developer, and I add bugs in Code

PR Merged – #5074

Because spaces should have height too!

PR Merged – #5089 #5100

The Butterfly Effect of Fixing Bugs!

PR Merged – #5107 #5118

1st July – 31st July

The Art of Scaling Fonts

PR Merged – #5125 #5126

Regressions: I make code, then I break code

PR Merged – #5158 #5136 #5152 #5153 #5156

It’s not you, It’s me!

PR Merged – #5163 #5164

Creating sandwiches in Total Distortion!

PR Merged – #5191 #5190 #5176 #5178 #5196

1st August – 21st August

A background window

PR Merged – #5221 #5216 #5233

Reading Books in Total Distortion

PR Merged – #5182 #5245

The End

It was a beautiful and fun journey, these last three months were filled with endless learning and I couldn’t express how much grateful I am for being given this opportunity! The community is very impressive with lots of helpful members, for anybody looking to contribute, I would totally 200% recommend them!

Moreover, although GSoC is coming to an end however, I am planning to become a member of the Director Engine team and continue my contributions in the future, so expect occasional blogs and my presence in #engine-director channel!

With that being said, here’s the hall of fame, and my heartful gratitude to these people for being part of this project:

Hall of Fame (My gratitude list)

  1. Sev (Eugene Sandulenko) – First and foremost, Eugene, as my mentor, is probably one of the best people who have guided me. honestly, I didn’t expect any learning outside anything related to this organization (ie I expected to learn more about C++ ONLY) but to my surprise, the amount of growth I have seen in myself is surprising to me, in these three months I have learned from basic skills like communication, to how to use git, how to develop efficiently, to even reading gdb stack traces!!I am really thankful for the patience, and for not giving up on me despite so many mistakes, etc! The only reason I got my proposal selected, to complete this project (If I will be passed) will be amazing super-mentor Sev!
  2. My friends and Family – These last three months, I was especially very busy, didn’t pick up anybody’s call, super-duper unavailable! So shoutout to all my friends for understanding this and being there in support whenever needed, I am so grateful for them that here are some mentions to each of them
    1. Sahil Kadiyan – My best roomie who inspired me to work, a source of endless motivation and energy that pushed me through to do something with my career (and that’s how I found GSoC)
    2. Radhika Agrawal – For understanding my unavailability in all these hard times, and for being there for me in thick and thins!
    3. Abhinandan Singla – For managing all the other projects, and academic work, so I wouldn’t feel academic pressure while working for GSoC, He was a lifesaver.

With that being said, I look forward to submission and the final evaluation results! It was a great tenure and I will continue my support to this wonderful of an organization through more long-term contributions!

Categories
Coding Experience Fun Opinion Technical

Reading Books in Total Distortion

Greetings everybody! Just before we start, I have something to tell you all, It’s about time and we are in the final phases of GSoC ending, the final mentor evaluation is about to happen (2 weeks~) and unfortunately, that means my tenure will be coming to an end! With that being said let’s start with my work this week! (plus what has been merged)

This week I have worked on fixing more bugs and improve more support, let’s start with the title!

Reading Books in Total Distortion!

Linked to https://trello.com/c/ZMRuRYA0/632-index-books-overflow where in books library the index in book was overflowing (see image)

image.png
bad (or bugged) render of books

Now, like any good sensible developer I took it upon myself to fix this issue! To do that I have to investigate, that how this thing is different from other “texts” in Director.. and I found that:

Style: Scrolling and that’s it! The difference was that this “text cast” has this style “Scrolling”, which was giving issues as in ScummVM we didn’t implement “Scrolling” textcast! You might have been confused about one thing: What is “Cast?” or “Text Cast” here??

Well a cast is like an element of movie, it is like the building blocks of any game/multimedia in director engine, and among these elements, we have many different kinds, for example Image cast, text cast, filmloop (series of frames), digital-video etc etc. Now each of these building blocks can have properties, like here TextCast member has this property of Style, where we can choose what kind of cast that is!

The Cast terms originally coined right after movies

e.g. it is one of the actors in a movie, you put it on a Frame, and Frames compose a Score
~ sev, (#engine-director, discord server)

So as I have previously mentioned, there is only simple text cast implemented in ScummVM, therefore, what I had to do is to simply implement a scrolling cast member! One  that takes into account a scrollbar in side and the logic to click items in it!

Well to do that, I just reused the TextScrollingWindow (ie a special kind of window specially created for displaying text in mac styled windows), well I had to do this because of scrollbar, that I needed in order to implement this scroll behaviour! Now as a part of doing this, what I was basically doing is to reuse the code that was written for text display, google says about code reuse:

Code reuse aims to save time and resources and reduce redundancy by taking advantage of assets that have already been created in some form within the software product development process.
and that serves about right! I could have simply written everything into default text class (which was used to mactexts) however the thing is, to do that I have to add scrollbar, its render, then event functions.. basically all of these were there in textwindow itself, so why do that all again when all you can do is to reuse it!
and that is how, after fixing it up, and making more changes to make it work properly, here’s the final result:

and that’s how the working books look like, Happy Reading!

Link to PR – #5182

More work done

Fixing visibility issues when setting window properties

There was this bug where assigning windows property automatically used to bring them to foreground, but this was not good as it means that sometimes hidden window that are supposed to be hidden are now shown, to fix it all I had to do is to remove the statement that does this and voila, fixed!

Link to PR – #5245

Refactor frames loading, fixing chan command

If you have been reading my blogs for a while, you must be knowing about one of the biggest changes to frames loading, well there are still some things that pop out occasionally, one of them being this debugger command “chan <number>” which was used to list channel information on any specific frame! The fix was simple, to refactor some things and fix the logic!

Link to PR – #5255

The End

Thank you for reading so far, its been great writing and working for scummvm and I really enjoyed this whole journey! Before ending I’d like to say that I have been offered to become member of this organization (Director engine), and I am very happy for that! (the process is still underway but expect the results next week), what that means is I can officially start directly committing codes to scummvm, and get some perks (cool discord roles, etc!). With that being said see you in next article!

Categories
Coding Experience Fun Nerdy Talk Technical

Creating sandwiches in Total Distortion!

Greetings everybody, in this blog I will be going through my work for this week! So first of all like everytime let’s start with title!

Creating Sandwiches in TD!

Well, amazed? Just let me explain what I meant, so in this game of total distortion-win, there is this minigame/feature to create your own food for exploration. Why?

Because the story follows a guitarist who teleported himself to a faraway dimension called “Distortion Dimension”, where he must collect unique sounds and ideas to create his next blockbuster! (And thus make a return trip to earth)! In all of these ventures, He needs to have ample health (including mental and physical prowess), and that is where food comes in! The food in total distortion is created using something called “Food Goo”, and sandwiches are just one of the many things you can craft!

That’s it for background, now when I was playing and testing game, there was this bug where I could not change ingredients while creating food/drinks, and that left me quite unsatisfied (and hungry too, getting to eat only one type!) It has been documented here – https://trello.com/c/CexIGcq8/629-food-maker-up-down-item-change-keys-not-working

So with a sense of responsibility, I took it upon myself to fix this and with some tracing, debugging.. It has been found that the problem lied to this statement:

do("set sProtein2 = the number of items in sProteinDB")

Here, the up/down keys were not working because of the anonymous script that is being executed inside (ie set sProtein…), Why?

Because in traces it has been found that

varFetch: variable sProteinDB not found

and so, the whole logic short-circuited and the change in items were not being registered! Well after debugging it has been found to be a problem with how Lingo anonymous function execution works inside handler of factory!

The part do(…), is anonymous calling of script, because it dynamically compiles and execute whatever script or command you feed to it at runtime (just like Python’s eval function), and just like that when the statement was being executed, It didn’t have any idea about sProteinDB which is instance variable (or object variable) for factory! Now since the command is executed in a different Context (or background) therefore It didn’t have any knowledge of object variables and thus that error!

The Fix? Well it was easy, I added a simple check that allowed me to share underlying factory context when the call is made to an anonymous function belonging to factory/script! This allowed the function to view/modify factory variables and thus fixed Sandwiches in total distortion!

Now that’s what you will call a YUMMY change!

(Please ignore the sound when sandwiches are created.. kinda gross)

PR Link – #5191

Making Buildbot Happy

This week, I also dedicated some time in looking at director build bot leaks. If you don’t have much idea, I strongly advise you to read the section “Leaks are annoying (and dangerous)” from my previous blog, At that time, I broke things due to not checking for leaks which made Buildbot quite unhappy and complaining however this time, I tried looking into some common existing memory leaks and fixing them! While doing that I came across one where an “Archive” (ie a structure to manage resources used by game) was leaking when changing Shared Cast. Well don’t sweat up technical terms but after like 4-5 hrs of debugging through code and frustrating nights, I finally found the problem and fixed it!

Results? A good spam and buildbot happy!

buildbot reports on discord, green means what has been fixed since last build
me and sev agreeing on satisfaction of the green spams

PR Link – #5190

More work done this week

Rebuild frames when jumping to the current frame

As on-demand frames loading has been finished and merged, new bugs and regressions keep popping up, just like how in Majestic-win there was the freezing when opening game, I investigated this and fixed it up with simple change.

Link to PR – #5176

Fixing black patches in Mediaband

and there was this regression, where mediaband had black patches all around the screen, again after tracing and debugging where could be the problem, It was fixed with PR #5178

Improve screenshots comparison for buildbot

This one is an upcoming feature for our buildbot, as you know currently we don’t have any system to compare screenshots of game, we only run them and see debug logs for any problems, However in some time we will be implementing frame-by-frame screenshot comparison, so buildbot can flag changes that potentially can break graphics, palettes, rendering etc! (Just how cool is that!)

As part to support that transition, I improved the algorithm for screenshot comparison, initially MD5 of image bytes were compared but since this method wasn’t foolproof, I implemented logic to simple compare each pixels of two screenshots and check if they are within threshold or not! PR with change – #5196

…and that’s it for this week! Before ending up

I have something to tell you all, my university will be opening tomorrow, and I really hope that it will not affect my pace of working, or fixing bugs. But as much as hopeful I want to be, there’s no telling about delays, or slowing down in the future! So I hope everyone keeps up with it and keep looking forward to next blog post!

The End

Thank you for reading up, If you are still here with me, I’d like to express my sincere gratitude for reading this up, the support of fellow readers is one of the thing that keep me up and inspire me write creative/fun blogs. I hope it was a good read and like always do forgive me for any bad writing/grammatical mistakes, etc. With that being said, Adios!

Categories
Coding Experience Fun Technical

It’s not you, It’s me!

Greetings, everybody. Welcome to this week’s blog post! I hope you are all doing fine, so first of all let’s start by this blog’s name, why “It’s not you, It’s me”, Well there’s the reason behind it as one of the bugs that I encountered has to do something related to this term ‘me‘ and thus when referring to this problem, rvanlaar (discord) used this as a joke… more ahead..

Let’s start with good news

Frame Loading Revamped

As presented in so many previous blogs, we are finally reaching the completion of demand frame loading and successfully working on total distortion’s bed dream games, this single big change took so many weeks, and after much effort frame loading has been completely revamped and the master branch is now updated to use on-demand frame load. If you do no know what I am talking about, read this and this to get a basic idea about the change!

PR #5124 by super mentor Sev laid the groundwork for frame loading by merging some 40 commits into master and thus the era of demand loading came! However, some more tweaking had to be done to get everything working properly and most importantly, getting total distortion bed dream games working, for which all this was started!

So after I made more changes and fine-tuned things after which bed dream games started to function normally.

Preview:

PR Link – #5163

It’s not you, It’s ME

Finally, to the fun part, bed dream games were fixed, so what next? To go next part and play the minigames (the bulb one you see in the above video, at the end).. but while testing it, I encountered another bug documented here, that is:

################ LINGO: syntax error, unexpected tINT at line 1 col 13 in NoneScript id: 0!

What does this mean?

To explain it better, I would have to give you a brief idea of what lingo is, and how is it used! But first, you need to know that the Director engine(for which I fix bugs) is a multimedia authoring platform, oh btw

Multimedia authoring is a process of assembling different types of media contents like text, audio, image, animations and video as a single stream of information with the help of various software tools available in the market.

ie such a platform needs different tools and things to control/create movies, and games.. Similarly in director engine, there is Lingo, a programming language that can be used to control various elements of games, like sound, images, etc!

Quoting from this Wikipedia page about lingo

Lingo is a verbose object-oriented (OO) scripting language developed by John H. Thompson for use in Adobe Director (formerly Macromedia Director). Lingo is used to develop desktop application softwareinteractive kiosksCD-ROMs and Adobe Shockwave content.[1][2]

So it is a language that was originally used with director engines, now to replicate that engine in scummvm, scummvm must support reading/parsing this custom language right?

How is a programming language understood by the computer? or more specifically, how is lingo being read by scummvm? Well to understand so, we have to deep-dive into compiler designs and things even I am not comfortable with, but in a nutshell there are these components:

  1. A compiler, which takes for example Lingo and converts it to C++ comfortable instructions.
  2. AST Trees for operands, operations, etc.

Oh, Lingo is a context-free language, I would really love to go deep inside automata theory but that’s an article for some other time!

But what happens, in a nutshell, is a simple instruction like put “Hello” when read by our compiler/parser, jumps into state, ie, converts everything to the token and then token-by-token creates logic/relations etc about different components of instructions, for example here let’s say our parser was initially in state X where it can accept a,b,c,d…. tokens, “put” being one of them, once it received “put” token, it simultaneously jumps into state Y where now it can only accept token like " , etc.. well, all these are then converted to C++ objects which will later be used to execute lingo!

What did go wrong with this bug?

Well, as seen by the error, called syntax error, what happened was that the game was trying to execute an instruction that is little different than what scummvm expects, here in this case, the game tried to execute lingo instruction

me(bubdie2 5, 75)

however, we expected an instruction of this type to be written something like this:

me(bubdie2, 5, 75)

(Please note the comma there), until now, there were no cases observed when a game used the wrong syntax (well correct, to be precise, just non-documented syntax), which was working fine in the original engine, and once again, we didn’t implement this peculiarity!

To be extra sure that it’s “us” not “them” who did this wrong, I verified this by creating testing movies for the director engine and trying to work this off and as expected our Lingo parsing was incomplete as it didn’t account for this edge case! Well time to fix it (but with a twist)

As this was too difficult for me, again super mentor Sev came to the rescue, he told me the problem and after discussions, djsrv implemented this, Link to PR: #5170

Here’s a working screenshot:

screenshot showing working dreamlights minigame

Oh, by the way, this title was inspired by this message of rvanlaar

You can always join our discord using this link and watch progress, and even better contribute and help improve ScummVM!

More Work this Week:

Fixing leaks in lingo-tests: #5164

This fixes leaks, and errors in lingo-tests which makes the build bot green yet again!

The End

Thanks for reading so far, I hope you like it, as usual apologies for any grammar mistakes, etc! With that being said see you in next week!

Categories
Coding Experience Fun Nerdy Talk Technical

Regressions: I make code, then I break code

Greetings! First of all, I would like to apologize for the long break. I was on leave and thus could not find time to be active here! So it’s time to be twice as hardworking to finish everything that lagged behind! (And create quality blogs as well XD)!

So this post is about regressions, what are they, and how do they work? Well…

A software regression is a type of software bug where a feature that has worked before stops working. This may happen after changes are applied to the software’s source code, including the addition of new features and bug fixes.
Again, google to the rescue! But anyway, so you get the general idea! It is about something that used to work (but not now)! So what happens is that in a big project with many moving parts, It is almost impossible to keep track of what new code changes can break other features. Even a seasoned programmer can make mistakes of accidentally breaking some other parts of code while implementing something new. (or perhaps fixing bugs) 
Although checks are in place, which help avoid frequent regressions like Buildbot tests ScummVM uses where each new addition is checked against several test cases already prepared, and their output is compared to expected ones! This is all automated, so much testing is done without much effort (except for setting it up XD).
So it’s been so many weeks already, and as we speak, I am on my last day for mid-evaluation. One question you might ask is:
“Hey HSK, working for so long, didn’t you break things? ie Regressed something?? I see all the good codes and how everything is magically working but where’s the dark part??”
The answer is

Regressions Introduced:

Popup Menu leaks

Linked to #5005 where I first implemented the popup menu, there are some occasional memory leaks(if you have no idea what this is, read the section “Leaks are dangerous” from my previous blog), which I have yet to find concrete ways to reproduce, however with some time I am sure it will be fixed.

Symbol and String Comparison

Related to #5107 where I fixed a comparison between symbol and string and evidently a lot of bugs in total distortion, Well.. I was wrong, Symbol and String are never equal on basic level, just sometimes when used to retrieve items from list using those as keys, do they behave like same! Fixed in #5158 where I moved the code to appropriate location and get everything working.

BDFScaler Scaling

Related to #5125 where I improved the text font scaling algorithm which was initially implemented by another student, however even though I managed to fix many bugs but there were still some more left which were very tricky and we had to disable that feature again in-favour of better GUI.

WinFonts Scaling Memory Leaks

Related to #5126. where I initially implemented Windows font scaling, well some leaks were not being accounted for (ie, scaling fonts), fixed in #5136

Well, even as we speak, and for the sake of open pull requests, We are never sure when another regression is introduced, but what I can do is make sure to fix the regressions and thus help in improving the stability of the director engine! Let’s look at some of the ways to fix/identify regressions:

Git bisect to save us here!

Read more about the git bisect command from here, what it does is to use Binary searching to systematically checkout commits and ask you if the commit is “good” or “bad”, depending upon your answers it will point out where things broke!

It is such a simple and powerful feature that you can traverse thousands of commits in 10 iterations! (for nerds that will be log2(1000) or 9.965 iterations, don’t ask me how)

It is so good that I once wrote a tweet about it:

that is it for the regressions and the dark part.. let’s see what I fixed for these weeks and my work so far!

This week

Use “me” to set “the perFrameHook”

Implemented in #5152, this allows for expressions like

set the perFrameHook to me

total-distortion was using this to assign hooks to call itself perframe using this expression, this is a special case where “me” is used to point current object instance to set “the perFrameHook” property!

Fix the working of m_perform properly

m_perform is a lingo handler to execute an object’s method, much similar to “do(command)”, there were errors when this was used inside mAtFrame, but after proper debugging and discussions it has been fixed by a change in #5153, however the change was little unorthodox so a test is also created in-case it breaks in future.

Fix the execution sequence of lingo scripts in case of frame jumps!

As fixed in #5156 where lingo executions inside the handler were being called immediately after frame jumps, ie (go commands) without waiting for the frame to load. Fixed this by freezing the execution of lingo and waiting before the frame is properly loaded before executing any remaining window!

 

The End

Thank you for reading so far, I would love to hear your thoughts and any feedback/suggestions, as usual apology for any grammatical mistakes and writing errors and especially the long delay for this blog, anyway with that being said, see you next week!

Categories
Coding Experience Fun

The Art of Scaling Fonts

Hey! Welcome to yet another blog article showing my progress this week, before starting let me remind that for this long week I was on vacation and therefore the progress is very slow, but regardless here’s what’s been done since last blog!

The Art of Scaling Fonts!

If you remember, my last blog where Fonts text height were fixed and text was aligned properly, this week I tried implementing scaling of Fonts (ie character scale) for windows font and fixing bugs in already scaling code for BDFonts!

Let’s start with terminologies and keep it aside!

What is BDF?

Wikipedia says:

The Glyph Bitmap Distribution Format (BDF) by Adobe is a file format for storing bitmap fonts. The content takes the form of a text file intended to be human- and computer-readable. BDF is typically used in Unix X Window environments.

https://en.m.wikipedia.org/wiki/Glyph_Bitmap_Distribution_Format

What is Glyph?

A glyph is a single representation of a character.

In these bitmap fonts, what happens is that a single character (or glyph) is represented by sequence of bytes, now let’s take an example of character A

It is already understood that an image is combination of dots (ie black and whites), what we see as a 2D figure is actually a matrix with filled 0s and 1s, similarly the pictorial version of these characters (ie how A looks on scteen) is given by a matrix that will have 1 in places where a black spot appears.. (when seen as image this matrix will be seen as how we understand character A should look like :)!

How this matrix information is packed into text?

Let’s assume we have this character A which is 12 bits in width and 16 bits in height,

Now if you understand basic data types or logic gates, you can already deduce that it takes 1 byte to pack 8 bits, or here in this case 2 bytes to pack 16 bits

Also since height of this glyph is 16 bits, therefore it takes 16 x 2 or 32 bytes to represent full character matrix!

 

That is all in the basics of Fonts, if you understood it all, unfortunately I still cannot award you the prestigious certificate of completion in basic font terminologies as the real deal has lot more technical jargon like offsets, ascent, descent etc etc, but for our case only understand these bits will do!

So what is font scaling?

It is, as name sounds scaling each character to some size and thus using it, a good scaling is one in which the texts using font is still readable (and crisp), however in lot of cases it is difficult to moderate how good we scale.. Here at scummvm currently we implement a primitive scaler that works like:

1. Take each of the size parameters ie width, height etc and multiply it with scale (ie newsize/oldsize) round it off and that will be our new size!

2. For glphy scaling (ie the actual image part), what we do is to draw the character on empty surface and scale the surface upwards, finally we trace the scaled screen and convert it into bytes form!

3. This new object (ie scaled font) is returned to be used as per demand!

Fixing bugs in BDF Font Scaling!

Now bdf font scaler was implemented by a student themselves, and it was kind of not finished or let’s say not furnished and was giving crashes and overflows! So as usual I started looking into it and after some time found the source of error! Finally fixing it I was able to run the program with scaledFont..

But it doesn’t end here:

While debugging the already written code, I found lot of issues with gui, like different text preview with different size, artifacts in certain glphys and many other..

After spending some time finding and fixing, bdf scaler was fixed upto certain extent (however would like to mention that not still some minor issues persisted, which are still being looked through)

Link to accepted PR: #5125

Implementing Windows Font Scaling

Related to scaling of Fonts, I was asked to implement windows font scaler, these are in formats of FOND and FNT, etc with their own specifications etc, as usual I read up some old documentations and archives information about fonts and went to implement it just like how BDF Scaler was implemented! A day later it was merged and yay, there we have our windows font scaling implemented, now windows games using fonts of different size will be rendered!

Link to merged PR: #5126

The End

Thank you for reading so far, this week blog, I apologize for the delay for this weeks progress and as mentioned I will be fully active and working from next week so look forward for the next release!

Categories
Coding Experience Fun Nerdy Talk Opinion Technical

The Butterfly Effect of Fixing Bugs!

Hello! It’s nice to see you again XD Welcome to another blog article demonstrating my progress for this week! How was your week? I hope it was good, for me It was amazing as I was quite productive -> (Read More)

So Let’s start!

Justice for Texts, Granted

In my previous blog post I mentioned this text problem where some texts were getting jumped up while others were overflowing! Well, the great detective (err.. developer) HSK, successfully investigated the problem to be linked with fonts!

What was happening in the original behavior is that, while calculating line height (because look, for rendering all those texts, we need to know the exact dimensions they occupy) with custom fonts, the heights were just a very small magnitude different from what It should be (I mean, for some texts, adding 1 to all line heights fixed the problem, but broke all other fonts)

The Solution?

Was very simple. In the original implementation, they only used the font’s height but didn’t make use of another parameter, that is called “Leading”

The vertical space between lines of type is called leading.

After simply making a change, from

virtual int getFontHeight() const { return_data._fRectHeight }
to
virtual int getFontHeight() const { return_data._fRectHeight + getFontLeading(); }
Everything was fixed, WOOHOO!
Obviously, the warlock-100 (game for which bug was discovered), became very happy, as text alignment now properly works! (Screenshot below)
fixed alignment of “The Blaster” text, now matching with it’s play button!
Merged PR link -> #5100

Game Save loading Error – Total Distortion

This is yet another bug which was discovered while playing through total distortion, where sometimes there is corruption in game properties which, when saved and loaded again, completely crash the game!

This is an interesting bug because It made me unable to progress further (and was quite annoying)

Details for this -> https://trello.com/c/TllLPBYZ/626-game-save-loading-lingo-parse-error-totaldistortion

Oh, by the way, there is a public Trello board for tracking bugs and issues. You can always look there to know the current state of the engine!

So again, after lot of digging through I finally found the rootcause of the problem! That was a simple comparison check:

In certain parts of games, two similar but different types were being compared (for example, you can compare Integer 4 and string “4” and expect them to be true). Similarly, it was happening that two datatypes of Director Engine Symbol and String were being checked for equality, now being similar but also different, ScummVM didn’t take them into account and just returned false even for similar ones and thus, this small issue was giving big troubles! The Fix was very simple, that is to tell scummvm to treat Symbol and String comparison by “String” way!

Just for reference, a symbol in Director looks like #mysymbol, while a string is “mysymbol” like if you also have doubts that WHY? aren’t they same?? Well they are not.. let’s see what books say about this!

A Universal “Name Constant”
Symbols are something special to Lingo. They’re sort
of a “name constant,” giving you the portability of
string names minus the computational and data
overhead.

Lingo! (Tab Juilius)

Well, Let’s not go deep into the technical aspect of this, just know that they are similar but distinct!

And finally, here’s the fix: #5107

Butterfly Effect of Fixing Bugs

Bonus section! So I remember my mentor said this when I was starting to submit a proposal in GSoC! He told me:

and look, we are not testing GAMES, we are testing Director, so, there is a beautiful side effect they break because some feature we implemented is not correct or absent 
How is this relevant to my previous bug fix? Well, those words were precisely correct, they couldn’t be any more truth to what I do every day! The more I get into finding and fixing bugs, the more I realize that they are fixing many other things that I have no idea of!
This was very much visible in my last bugfix of symbols comparison, where once I fixed it and was testing game again, I observed that many big and small bugs were also fixed, and the game suddenly got a lot-lot better… Just like that!
That’s why putting emphasis on the butterfly effect of fixing bugs, you fix one bug, It fixes another, and that.. fixes another as well! (The converse is also true, make one bug, destroy the whole program)!

Listing out things that were successfully working in total distortion:

shops and calling feature working!
video sequencer now opening without crash!

Finishing what I started – Meet Mediaband’s UnDo Me

Now comes the last and most nostalgic part! One of the first things I worked on after being introduced to ScummVM is Quicktime Video playback!

Yes, I cannot remember exactly if this was my 2nd or 3rd task, but what I can remember is this was one of the things that gave me an, even more, deeper understanding of the codebase and made me familiar with how things work when you play video!

Anyways, so in the month of March-April, I was given the task to implement custom playback rate and reverse playback for Quicktime Videos, you can just think of it as how your video player can be set to play at twice the speed skipping boring university lectures (Yes, I have done it too, personal experience), but here It was no movie player, here it was ScummVM, and we needed this functionality for this game meet-mediaband where one of the movies were using a miniature sort of video-player with different playback speed and this was all a part of UnDo Me.

A little bit about “UnDo Me”

well, it is a very simple game where you can choose between four romances for our lady and have two controls, “Ice” and “Fire” for going passive or aggressive to different situations and scenarios that will be played throughout the movie, while there are two buttons “Un” and “Do” for reversing/resetting story and for quickly going forward)! This clever game was implemented by seeking different parts of our QuickTime movie! You can even watch this youtube video of gameplay

Continuing on,

In the months of March-April, I implemented this custom playback but didn’t implement/integrate this with UnDo Me (the very game for which it was made), fast forward to 2 months, and suddenly we got a fully explained video of mechanics, and how it looks like, sev (my mentor) asked me to look into it and I knew, This is destiny… (Well I was supposed to finish it either way :P)

Fast forward to another sleepless night and voila! We have our UnDo Me working with all the controls working and a smooth experience! YAY!

Also, special thanks to fracturehill and their PR #4965 that made this integration possible (because setting custom rate audio was not implemented when I first started looking into video playback)! Not only that I must thank him for finding a bug that I mistakenly thought was due to their work(In the end, it was me who didn’t debug it thoroughly)! And being so helpful!

undome in scummvm!

Link to PR – #5118

Ending Notes

As usual, thanks a lot for reading all the way up to here! Apologies for any grammatical, or writing mistakes (My Grammarly is screaming right now), and with this see you next week!

Categories
Coding Experience Fun Nerdy Talk Technical

I am a Developer, and I add bugs in Code

Quite an ironic title, right? Must be thinking I am joking, but hey! What if I say this is all true?

Now before getting to this fun story and about how exactly I am adding bugs in code, let me present to you the definition of a bug! As been talked about by my mentor!

Eugene Sandulenko (aka sev, or my mentor) said:

bug is typically a problem in code of unknown nature

And here is something which I found on Google:

A bug is an unexpected problem with software or hardware. Typical problems are often the result of external interference with the program’s performance that was not anticipated by the developer. Minor bugs can cause small problems like frozen screens or unexplained error messages that do not significantly affect usage.

I hope that makes it clear!

Now coming to the good part, I am a software developer, a GSoC’er this year, and most of the time, I resolve bugs, but sometimes I add them too!

The Story

To start with the story, first you need to understand what exactly is my work as a GSoC’er in this organization called ScummVM! So let’s start with basics:

What is ScummVM?

ScummVM is a program that supports numerous adventure game engines via virtual machines, allowing the user to play supported adventure games on their platform of choice. ScummVM provides none of the original assets for the games it supports, and expects the user to properly own the original game’s media so as to use the software legally.

This is what Wikipedia says about us, but in layman’s terms, What we do is to bring compatibility of these vintage games to our modern platforms! We do this by implementing engines in C++. These engines take in-game files, and are able to run them! If you have even a bit of idea about how Unity works, Unity is a game engine; just like that, there are very, very old studio-made game engines using which games were made! What we do is recreate these engines so that if one has the game files for their favorite old games, they can now play them using our software!

What is my Role for GSoC’23?

quoting the bulletin news board itself, it says:

  • Harishankar Kumar will work on improving Director 4 Compatibility. The goal is to reach full support for Total Distortion & The Journeyman Project. You can follow the progress for this task on Harishankar’s GSoC blog

Oh, by the way, If you don’t know. I am Harishankar Kumar XD (And nice to meet you too)

So, what I do, is to improve compatibility for Director 4 Engines. Now, the fun thing is that these engines are made by taking some real vintage game engines as a reference! (In my case, it is Macromedia Director 4, released February 28, 1994) and with these engines come their own quirks and behaviors.

Do you see where I am getting at?

Replicating the Perfect Engine

As part of replicating the perfect D4 engine, I have had to fix many bugs. These bugs were also what made me reach this point, get selected as a student, and write this blog but It is all great when you are fixing a bug that is in ScummVM by taking reference to how the original (ie Director 4) should work, but what will happen if we were to perfect our code such that it is even better than the original? (In some aspects)

Oh yes, you heard it right! So here’s the STORYTIME!

What happened?

As part of taking reference of original and how documentation, books etc says things should work (in Director 4 Engine), our software at ScummVM was developed such that it followed the rules.. however in pursuit. of this excellence, we made big mistake.. that is

Implementing something that is better than the original!

Oh yes! Now if I delve too deep into technical aspects, It will be too difficult to understand, but let’s just say there was this functionality of engine that allowed it to do something, however as part of doing something, It was also doing something else which it was not supposed to do, this something something was something that our software ScummVM was not doing (so we were good, following rules, documentation, and books) however because we didn’t do this something that the Director 4 was doing, our program has bug..

Well, to be precise, the bug was in the original Director 4, however since we perfected ourselves too much, we surpassed the original engine itself (in this feature only, It would be very, very arrogant of me to say we really surpassed the whole engine itself, if that were the case I wouldn’t be there doing something’s riddle to you)

Adding bugs

Now comes the good part, which is adding bugs! Well, this is only a figure of speech because, in reality, I was not adding bugs to this software. I was implementing this non-documented weird behavior (or a quirk) that is present in Director 4 engine, and thus doing my part as a responsible developer!

Now this is a bug of the original Director 4 because It is not how the games built on D4 were used to use.

It was either a genius or a complete idiot who used a quirk of software to do their own work and release this into production! (I still believe they are genius to use something in such a way that is written nowhere, completely unique)

Only god knows if this were intentional. However, the amount of work this adding “small” bug cannot be underestimated because it made us question the fundamentals of the engine and required some heavy changes!

But one thing is for sure, We are moving forward towards creating a perfect director experience, either its features.. or its peculiarities in the form of BUGS!

My work this week

Even as I am writing this blog, I am side by side working to implement this peculiar behavior I just mentioned, however this week, I managed to get another pull request merged, that is #5074

Not only that, this week was quite hectic with all these findings and verifying proper behaviors with respect to these non-documented quirks. I wrote several tests to check and verify their behavior in scummvm!

Ending

Thanks a lot for reading this! Do comment out your honest thoughts and opinion about this blog and follow the series for more of such interesting content!

Categories
Coding Experience Fun Technical

Implementing Mac Styled PopupMenu’s, First PR After GSoC Accepted!

Introduction

This is a blog and demonstration for my first pull request that got accepted after getting selected into this program! I plan to create a blog entry for each of the features/major changes and keep my audience updated!

Anyways, so the first task was to complete something called Mac popup menus, if you don’t know what it is, then It is nothing but a popup menu (i.e., those whom you click, and they give a bunch of options)! Now this was not completely my work but was of someone else.. I was only tasked to complete their work..!

Menus - Material Design
A typical popup menu

The Menu..

The first thing I did after getting this task was to read the codebase, understand how the menu works and try to understand how the existing code operated! To be frank and honest, this actually took me quite a time, plus university examinations were already taking lots of time!\

Anyways, I kept on reading codes, making changes, getting popup menu to be implemented however..

THE CODE WAS VERY BAD

Ahh.. sorry for shouting, lost my composure there for a second :)! Anyways, by code was very bad I don’t mean the code written at ScummVM (this organization), no it is a piece of art, but I mean the code written by the person before me (the unfinished code).

The more I kept on understanding it, hacking it, etc, The more changes I had to do, at some point of finishing their work, I had to change everything from scratch and implement major functionalities myself.

That day I understood, what happens if you write workaround code in big production software, you make life difficult for the people taking your work, sigh.

Anyways, so getting to the main topic.. I was tasked to implement an unfinished popupmenu, for many of you still not getting feel of what this “MAC STYLED POPUPMENU” (of vintage ages) looks like, here the photo taken from Basilisk II (Mac 7.0 Simulation)

Original Mac Popup Menu, as taken from basilisk II

Looking at the state of the popup menu and current implementation, there were many big and small details that needed to be implemented like:

  1. Alignment issues, the rendered menu was some pixels off it is supposed to be, and in some cases, it was very very far away! (We welcome you, Desktop Mode)
  2. BAD CODE, Improper variable introduction (A variable was there just for bad workaround of bypassing some loops, calling some particular functions.. etc)
  3. Many features not implemented (Like smart menu which remembers your last choice), checkboxes, remember last item, etc!
  4. Some more small bugs that were found on the way, needed to be resolved for proper functioning!

Over time, with proper and lengthy discussions and regular updates to mentor, these bugs were addressed and we reached to a point where popup menu in ScummVM were working (demo gif below):

The final result after implementing the popup menu!

Overall this was quite fun to work with, I got a good understanding of how Mac styled windows (not only popup menu) are created and used throughout the project! Director (the engine I work on) was first built for Mac systems, and thus I believe this knowledge of fundamentals would be very useful for long-term contributions!

Plus it was quite fun to find English-ordered alphabet items on the menu (I bet you didn’t notice) ><! (ie the menu items are Apple, Banana, Cherry, Duck… etc, ordered by first alphabet)

Anyways, with this my first pull request after getting accepted was finished, It was successfully merged (After many review rounds and corrections), here is the link to the pull request – #5005!

It doesn’t end here

My frequency of writing blogs do not match with the speed of my contributions! and thus by the time I started writing this, and by the time I reach to this section.. another two tasks were given, I completed them, and the prs are merged! Giving links, they were #5056 and #5059!

These were technical bugfixes/implementations, things that do not have intuitive GUI that I can show (and you understand)! But hey.. Let’s have an easter egg before I end this, and that is:

The Jumping Windows! #5059

A part of the task given to me, (that I solved in pr #5059), was to implement window location set/get functions, in layman terms basically each Mac window (that’s what they call it XD) has this field called rect which can be used to set/change their location!

Now this function to set the window location was unimplemented, and thus there was this thing where it you are supposed to click on “Change” and it will alternatively teleport(err. move) the window between two positions! Initially before implementing, it was not working but after implementing this function, things successfully worked and the window was happily jumping here and there like a happy kid it is supposed to be.

And if you didn’t realize it, this section was meant to be a troll, (but still, jumping windows were good XDDD), anyways thanks for reading!

The End

Thanks for reading so far, I really appreciate each of you still here with me! Also apologies for bad writing style/punctuation/grammar mistakes, etc! I hope this was a fun read and look forward to the next part!