How was the cross-platform Half-Life or Headcrabs inside your watch created?

Published on October 14, 2015

How was the cross-platform Half-Life or Headcrabs inside your watch created?



A couple of months ago on Giktayms slipped the news about the launched Half-Life on Android Wear. The article did not say a word about the developers, and then one of the Khabrovsk residents asked in the comments why none of them would write here?

And now is the anniversary from the moment I started the port of the free Xash3D engine on Linux, and also, since some of my friends were still interested in the details, I decided to write this post. Anyone interested in the history of the project, workarounds of various problems and my personal advice, please, under cat.

I'll start with the history of the project. The engine was originally written by a programmer with the nickname Uncle Misha or g-cont. It is to him that we owe what we now have. Only in 2011 he posted the source code of the engine for GPLv3. But he had a fatal flaw, Uncle Misha did not want to port the engine to anything other than Windows. He wanted a certain amount for the Android port, and, of course, the idea failed because of our community.

I personally began to monitor the engine in 2012, a year after the source was opened, but only in the fall of 2014, with little experience in C ++ programming, I downloaded the engine source code. Burning with the thought that a free game engine and cross-platform are closely related concepts since Karmak times, I started porting it to Linux.

At first, the port was planned using winelib, but over time, delving into the architecture of the engine, I settled on SDL2, as the most ubiquitous multimedia library. And Valve used it for their ports.

And immediately, my first advice to those who want to transfer any application unknown to him to any OS:

1) Create project files immediately and, without making a single change in the project, compile it.

Yes, from my advice, your IDE may even freeze, as the compiler will generate more than a thousand errors and warnings. My compiler generated about 4000 errors.

Passing from one error to another, I gradually got rid of them. There was no Windows code left, -Wl, - no-undefined helps a lot when porting.

And so it happened - the engine loaded. It shows its own console, but outside the window, meanwhile, it was about the beginning of December last year. I must emphasize that before me, attempts were made approximately on the console and ended, if not earlier. All December it took to load the libraries in runtime, SDL input, sound - and here I am posting a screenshot of the work on Linux.org.ru.

Screenshots taken for December


That I once threw off EXL .



First public screenshot


Several people are interested in the work done. I look back at the source and understand that it is no longer possible to work with this: in many places the code becomes unreadable due to macros, strange bugs appear, assembly outside my localhost is very difficult. And the version of the engine is very old. In the comments to the thread, they indicate that new versions are distributed on some other forum. As a result, I start everything from scratch, and my friend helps to bring everything into a serious look - translates the assembly to CMake, chases me with bad-smelling rags for too large commits and govnokod. Also on GitHub, an SDLash3D organization is created, named after the old port. At the time of writing, there are already five people in it, but only two are active.

Suddenly, number 2, which I realized for myself at this time:

2) Make a header file containing only macros that will insert the code necessary for the target platform.

There is also advice for those who, while reading this article, write code in their studio.

3) At the expense of any suspicious and strange code, contact Google. He will tell you that your code is compiled only for Visual Studio, which has many non-standard extensions. And less tie up on WinAPI.

Meanwhile, nicknekit / Unc0nnected silently starts porting the old port to Android.

Screenshots and videos kindly provided by Nikita






In February, Nikita and I began to work together on the port. It deals with the old port, and I finish the new one and transfer the functionality related to Android to it.

At this point, the basic scheme of the port on Android is installed. Now it looks like this:



In March, we create a thread on w3bsit3-dns.com, which we report on the success of the transfer, new videos and screenshots. On April 1, version 0.1 is released, but April 1 cannot be without a joke, so the condition is specially made in the engine under which it closes if pakandroid.pak is not found, in which a very fun and fairly high-quality G-Man mod was “wired” Invasion

Since then, among the significant events for the port were:

  • Support for touch control made in conjunction with Beloko Games;
  • The release of version 0.14, which really brought success. About 20 thousand visitors in two days, judging by the statistics on GitHub;
  • Android version interface for modifications made by our mittorn . Mododels can independently release their game also on Android.

You can end this, below the bonus in the form of separate commits and links to us on GitHub and ModDB.

Bonus number 1. Several commits related to different code understanding in Visual Studio and GCC. After fixing all of them, I’m sure that C support in the studio is the worst thing that has happened in the programming field:


Bonus number 2. Also some commits related to ARM, Android and OpenGL ES:

  • A bug with a strange multiplication and division by 1.0 by ARM;
  • More problems with float . Caused random crashes with SIGBUS;
  • And here is no link. Just suddenly I discovered for myself that all char on ARM are unsigned. That's why the NPC navigation went crazy, and sprites did not work in the engine. You can either insert the -fsigned-char switch, or explicitly indicate that char should be signed for this variable;
  • Render bug . Not really ARM problems, but OpenGL ES problem. Still not fully fixed;
  • Own implementation of dlsym () on Android , and all because in Android there was a bug before Lollipop that some symbols from libraries did not resolve;

Links :

Organization on GitHub .
Page on ModDB .

Thank you for your attention, your a1batross .