Working on Resource loading and Misc Refactoring

The main objective of this week was to start re-writing code that was stubbed while compiling the engine. We chose to handle the methods dealing with loading assets and reading configuration files first. This could be followed by writing code to render graphics, sound and rest of the components of the engine.

I started off this week with some simple refactoring tasks. I wrote a few shell scripts to automate this process.

  1. Wrapping the entire code under the QDEngine namespace.
  2. Remove redundant files.
  3. Add our copyright headers at the beginning of each file.

This weren’t as hard, but took some time to get done with.

The initial stage of our engine looked something like this. It was a blank green screen with multiple logs in the terminal.

Initial game screen.

Here on I started writing actual code. The process to deal with each stub is quite straightforward. You track down the function where the stub is being used. There on you understand how that is being used in the context of our program, and then eventually replace it with the appropriate ScummVM API. You can take a look at this commit for reference. For the final step, I would mostly consult with sev. He would give me a rough idea about which headers to include, and which APIs to study.

The initial stub messages were quite straight forward to deal with. They didn’t really have a very deep call stack, hence tracking them down was also quite simple. However after the initial few stubs, the process got a little more complicated, and I couldn’t simply track down the exact code flow. Even if I did, it consumed a lot of my time. Hence I chose to use a debugger (lldb in my case). The debugger gives you a complete break down of the call stack and the value of the variables which helps you reverse engineer your problem much faster. I would put a breakpoint at each stub message and check the call stack to understand how did we land up here. This really sped up my process.

The call stack leading up to GetAsyncKeyState STUB.

This week, I focused primarily on initial refactoring. Over the weekend, I began working on rendering the first graphic on the screen. I am currently in the process of re-writing this functionality and aim to render the splash screen next. Following this, I will explore how the engine handles game rendering.

I am excited about the progress and look forward to showcasing actual graphics in the coming weeks.


Leave a Reply

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