# hg2_sdl

**A custom SDL 1.2 build for Heavy Gear II Linux (2000)**

## What is included in the package
 - `libSDL-1.1.so.0` - This modified shared library is actually SDL 1.2.15. Please replace the original library in the game directory with this one to apply the modification.
 - `cd_wrapper` - A simple script which will be executed when the modified SDL trying to play tracks from CD, and the script will play audio files from the disk drive instead. The script is written in Python and require [VLC](https://www.videolan.org/) to run. But you can completely change the implementation whatever you like. This script should be placed in the game directory too.
 - `hg2_sdl.patch` - The patch file to the SDL 1.2.15 source code. In case if you would like to build the library by yourself. It's also a rightful way to honor the LGPL license, which is applied to the SDL 1.2 codebase.
 - `README.md` - You are reading it right now.

## What is changed in this custom SDL build?
 - `cdrom/SDL_cdrom.c` - The CD play/stop functions will now execute a external script named `cd_wrapper`.
 - `video/x11/SDL_x11video.c` - To avoid the black screen when switching from the in-game 3D screen to the 2D game menu in fullscreen mode. Note: the original SDL 1.1 build for the game doesn't have this issue.
 - `events/SDL_keyboard.c` - The PrintScreen key is explicitly bound to the command `gnome-screenshot`. Note: the game actually has the screenshot function itself, the saved screenshots will be located in `~/.loki/hg2/`. This code change is for some debugging purposes.

## Known issue
 - There is a OpenGL-related segmentation fault when shutting down the game in fullscreen mode. But it will not affect the actual gameplay.

## How to build the library (on Fedora 30)
```bash
sudo dnf groupinstall "C Development Tools and Libraries"
sudo dnf install alsa-lib-devel.i686 libX11-devel.i686 libXext-devel.i686 libXrandr-devel.i686 libXrender-devel.i686 mesa-libGL-devel.i686 mesa-libGLU-devel.i686
wget http://www.libsdl.org/release/SDL-1.2.15.tar.gz
tar zxvf SDL-1.2.15.tar.gz
cd SDL-1.2.15
./configure --build=i686-pc-linux-gnu --disable-x11-shared --disable-video-x11-xrandr CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32
cd src
patch -s -p0 < ~/hg2_sdl.patch
cd ..
make
cp build/.libs/libSDL-1.2.so.0.11.4 ~/hg2/libSDL-1.1.so.0
```

## Contact me
DarkRanger (https://darkranger.no-ip.org)
