Categories
Uncategorized

Finishing refactoring and implementing audio

Hi all, this week, I finally finished refactoring the code and feeling a bit adventurous, I went on and started work on implementing the last remaining subsystem – audio. In this blog post, I would like to detail to some extent what has been implemented in the audio subsystem and what is left to do.

A short introduction to the audio subsystem

CRAB utilized the SDL2_Mixer library previously, to play the background music and the various sound effects. Before reaching the main menu, the engine initializes the audio subsystem during which all the sound effects are read into memory. On the other hand, the background music files are only read as per need and are “decoded on demand“. It should be noted that the audio subsystem “fades-in” the background music, i.e., it starts playing the background music at silence and then gradually increases the volume to normal.

The audio subsystem also allows one to set the volume of sound effects and music channels independently according to their own taste.

The process of porting

Initially, I found the task to be daunting because I have never been able to fully grasp the different terms and concepts related to digital audio. I went through the documentation of SDL2_Mixer, and once I had a basic idea, I tried figuring out what equivalents were there in ScummVM code.

Decoders for both the OGG and WAV files were already present which saved me a lot of effort. Additionally, the mixer class seemed to fulfil most of my requirements. I did encounter a bunch of crashes at first and after a bit of trial and error, I was able to get both music and sound effects to work!

In the upcoming week, I’ll try implementing the “fade-in” effect of the background music and the ability to set the volume for the sound effects and background music. Thanks for reading!

 

 

 

 

Categories
Uncategorized

Refactoring code and misc. changes

Hi all, this week I worked on formatting the code to match the code formatting conventions set by ScummVM. In my opinion, this is a step in the correct direction as it would get the repo in a state where it could potentially be merged into main ScummVM branch.

What needed to be changed?

While most of the formatting issues could be fixed by running tooling such as clang-format, others need to be fixed manually. Majority of my commits in the last week have been around converting the function names to camelCase and prefixing member variables with underscore.

Initially, I thought it would be an easy job but once I actually got to it, it turned out to be really taxing and frankly – boring.

I started out by manually making changes in the class definition,compiling, going through the compilation errors, and then fixing the references and as you can imagine it took a lot of time.I could not shake the feeling that there should be some tooling that could help me out and make the process easier. This is where I came across the “refactoring” feature in CLion, which could automatically rename/fix the references. I tried it out and although not perfect, it has definately made the process easier.

As of writing, I have fixed the formatting issues of atleast 5 components – ai, animation, event, input, and item . Next week, I will be working on fixing the rest of the components. That is all for this week. Thanks for reading!

 

Categories
Uncategorized

Working on save game support

Hi all, past week’s progress has also been slow due to health issues. However, I have started the work on adding savegame support.

The rationale behind this step was that it would help cover more stages/levels during tests, since till now, I have not tested past stage 3. Once the savegame implementation is done, I and my mentors would be able to create savegames at different stages which we could share and test if every stage is working as expected.

Coming to the topic of CRAB’s save system, it works by dumping the state of all the game objects to an XML file which is later read to instantiate the various objects according to the values when the savefile is loaded. This includes dialogues of various characters present in the level. I found this to be weird because if I had to design a save system, I would only save the level number and when that would be loaded, the character dialogues would get loaded in as well.

Anyways, I was able to port the save system to be compatible with ScummVM but immediately there were some noticeable problems.

The very first problem was that font rendering in the loading menu is broken due to some reason(The glyphs for some strings are not rendered properly)

Broken font rendering

Next, due to the way keymapper has been implemented, when inputting the save name, certain keys get skipped. For example, when typing in “kartik” only “kark” gets processed since both “T” and “I” are bound to some game actions.

To remedy these bugs, I decided that I would simply replace both the save menu and load menu with ScummVM’s GMM load/save menus. This required a lot of changes to the save system but I was able to get it done. Pressing the save/load button would now open ScummVM’s load/save menus and not the original ones.

Improved load/save menus

While this does work as expected, my mentors want me to keep the original menus so that the user can use the original menus if they wish to do so.

This is all that I was able to accomplish this week. While savegames do work, a lot of changes still need to be made before it can be called complete. Thanks for reading!

PS: On a personal note, I would like to dedicate all the further work and the work till now to my grandmother whom I lost this week. I hope I continue to make you proud!