
A few days ago, on May 15, in
ScummVM , a well-known cross-platform set of game engines for the point-and-click adventure, a code branch was added with an engine that supports the quest classics, the game The Neverhood.
It was one of the most exciting and long projects in ScummVM. Talk about this masterpiece lasted for several years, and the forums regularly asked to add support for this game. It took two years to develop the engine, and I want to briefly describe how this happened.
')
It is worth noting that adding a game to ScummVM is not an easy task at all. Today, for about half of the engines, we managed to get the sources from the authors, but even in these cases, the code should always be rewritten. So, recently, quite a lot of games written originally in Pascal and Assembler come into the project, and to add them, everything needs to be translated into C ++. The other half of the engines turned out by hardcore reverse engineering (you can't say otherwise) when IDA is taken into service, and we slowly begin to mark the original engine with the names of functions, variables and comments, layer by layer understanding the logic of its work.
It is the second approach that was forcedly used with The Neverhood. Attempts to contact the authors were especially unsuccessful, they itched their hands, and in June 2011 the project was launched.
Project Chronicles
Initial data:
* 800 kb binary code
* Original in C ++
* 7.2 thousand functions
* 340 virtual classes
After two years of work of two people the result was obtained:
* 36 thousand lines of code
* 2 thousand methods
* 320 classes
The first commit was simple:
Author: johndoe
Date: Wed Jun 22 22:58:51 2011 +0000
NEVERHOOD: First code with basic detection
This skeleton is essentially standard, and the development of each engine usually begins with it. Oh, how many attempts to reverse the game for ScummVM ended there! But not this time, not this time. Two days later, the code was written for access inside the BLB archives, and two days later the graphics were decoded and work began on Module1500, introducing the game.
We are not stopped by the fact that the game is a hardcode. Most of the engines for adventure games supported by ScummVM are virtual machines (you can write a separate post about this), and their structure is not too complicated. Sometimes the original developers write the game scripts directly in the programming language, which increases the amount and complexity of the work on reversing dozens of times. Particularly difficult is working with C ++. Compilers of this language often use advanced optimizations, as well as virtual classes are translated into assembler as implicit calls, which causes even more headaches. Also, the fact that IDA and Hex-Rays do not really know how to work with pluses and have to use a lot of crutches also does not simplify the work.
Nevertheless, on July 4, the initial splash screen of the game earned. Although it is a set of clips in the Smacker format, however, even for this, it was necessary to implement a message system, screen updates, keyboard processing, dimming the palette, transition between scenes, in general, write almost 3,000 lines of code. A week later, the first scene was completed, and work began on the second scene of the game, Scene1002.
Further scenes were added one after another, every week. By the way, there are only 71 of them in the game.
By the middle of September 2011, when about half of the scenes were realized, the work on refactoring started. The original code, as expected, contained quite a lot of noodles. The standards of ScummVM are quite high, and to improve the quality of the code, we are always working to improve the structure, and often the architecture of the original engines. Neverhood is no exception, object generators, wrappers, and many functions have been added together.
The work was practically not carried out from January to July 2012, and in August a dozen more scenes were added and work began on sound. In Neverhood, the sound is encoded by its own, self-coded RLE encoder, and it requires simultaneous playback of up to three sounds in addition to background music. By the beginning of October, the corresponding challenges were added to all scenes of the game, and we began internal alpha testing.
After the second wave of refactoring, when a significant part of the duplicated code was thrown out, and the engine was heavily “lost”, the preparation of the branch for merging with the main code ScummVM began. For this it was necessary to add the menu, the final credits, the Hall of Fame room, as well as recording and restoring the game state.
On January 21, 2013, after a year and a half of development, we suddenly realized that the original hero was called Klaymen, not Klayman, as would be logical in accordance with the English grammar, and this insight was followed by a massive rewriting of variables and classes in the code .
A little more refactoring, bug fixes, and on May 5, 2013 Pull Request was made to the main ScummVM branch.
Here it is, the history of the project.
Briefly about the future
Work on the engine is far from complete. Now you need to make sure that the game works on all supported platforms, in particular, on big-endian ARM.
Also, so far, unfortunately, the Russian versions of the game are not supported, as our translators, as it often happens, slightly changed the formats here and there, and the engine in ScummVM falls after the initial splash screen. We are working on it right now. It is possible that we will work on adding support for the PSX version of the game.
It is also necessary to do some work on refactoring, in particular, to remove global constructors that are evil. And, finally, announce a public beta testing.
References:
The site of the project ScummVM , in order to run The Neverhood, you need the daily build version 1.7.0
Engine source codeHow to run the game
The game needs to be copied from the original disk, click the Add Game button in ScummVM, specify the path where the game is copied, and then the game will appear in the list (while only the English version and the demo work). Next, double click on the name of the game, the game will start.
Demo can be downloaded
from here . You can buy the full game on eBay, Amazon, also come across on the shelves of our stores Russification.