Categories
Uncategorized

Preliminary Work

Introduction

Sev promoted me to actually start the work on porting the CRAB engine after I had completed some tasks which he had assigned me.

On this page, I hope to document to the best of my efforts what work I have already accomplished as of writing this page.

Importing the Engine Source code into ScummVM

The very first thing, intuitively, was to import the engine sources into ScummVM and get them to compile. To accomplish this, I first created a new skeleton engine and then imported all the files.

Initially, I took the wrong approach, I focused on removing STL usage before anything even compiled and rewrote some functions. Sev later made me realize that this was probably not the best approach and that I should first focus on getting all files to compile, and then remove STL usage.

I got introduced to `FORBIDDEN_SYMBOL_ALLOW_ALL` which allowed linking with C++ STL(future engine porters take note :p). 

One thing that I took advantage of was that the src code of CRAB was well-separated into different components. So, instead of getting the whole codebase to compile at once, I instead made every component compilable one by one.

With commit #07a97c7f all files were compilable. It should be noted that I had to stub/comment out some functions as they errored out.

It is during this stage, that I also got the first visuals on screen by porting the Image class to use ScummVM’s equivalent of SDL drawing functions.

This is the game loading screen just before the main menu.

Getting game to render and running into issues

Next, I ported the text drawing functions and soon I was able to go in-game. Yay!

The game renders correctly!

However, if I pressed the left mouse button even once, the screen would simply scroll way past the point it was supposed to.

I spent days debugging this, and ofcourse, the problem was the new rewritten functions I had created :). Reverting those, fixed the issue and now it worked as intended. (A more techincal description: A templated function did not take into account that floats/doubles could be passed to it.)

One important aspect that I haven’t talked about is – Performance. Originally the game is supposed to run at 60 fps, however I was only getting a glorious ~6 fps with ScummVM’s drawing functions.

Optimizing performance

The very first suggestion I got was to work with the minimal – resolution that the game supported, which in this case was 1280×720.

This boosted the fps to 10. It was definitely not a massive improvement, but a improvement, nonetheless.

 

This is where the current progress stands. There are a few other optimizations which have definately helped but that is for a future blog post!

Thanks for reading.