Build Chocolate Doom on Raspbian for SP7021 Platforms

The goal of the document is to illustrate the steps to build Chocolate Doom on Raspbian (Debian 10) for SP7021 (Plus1) Platforms.

Please follow the following steps to build and run Chocolate Doom.

1. Install the necessary tools or libraries

Install the necessary tools or libraries for building or running Chocolate Doom. Please run apt-get install command to install them:

pi@raspberrypi:~$ sudo apt-get install gcc make libsdl2-dev libsdl2-net-dev libsdl2-mixer-dev python-pil

where gcc, make, libsdl2-dev, libsdl2-net-dev, libsdl2-mixer-dev and python-pil are going to be installed. Refer to screenshot when packages were installing.

2. Download source code of Chocolate Doom

Use web browser to download source code of Chocolate Doom from “https://www.chocolate-doom.org/wiki/index.php/Downloads”.

Or use wget command to download source code directly:

pi@raspberrypi:~$ wget https://www.chocolate-doom.org/downloads/3.0.0/chocolate-doom-3.0.0.tar.gz

Refer to screenshot when getting “chocolate-doom-3.0.0.tar.gz”.

Run ls -al command to make sure the .gz file was got.

3. Extract the package

Run tar zxvf command to extract the package:

pi@raspberrypi:~$ tar zxvf chocolate-doom-3.0.0.tar.gz

Refer to screenshot when extracting “chocolate-doom-3.0.0.tar.gz”.

Go to directory chocolate-doom-3.0.0 and run ls command to check the contents.

4. Fix a bug for RGB565 format

There is a bug in source file src/i_video.c of Chocolate Doom version 3.0.0. The bug causes Segmentation fault happening when chocolate-doom runs on machine with screen pixel format RGB565. Please use text editor to fix it as shown below:

Value of variable unused_bpp will be 16 if pixel format of screen is RGB565. Value of variable unused_bpp will be 32 if pixel format of screen is RGBA8888 or ARGB8888. The 4th argument of function SDL_CreateRGBSufrace(…) is depth of a pixel. Use fixed value 32 is not correct for the argument. Replace 32 with variable unused_bpp.

PS: The fix has been merged to //github.com/chocolate-doom/chocolate-doom. Refer to commit 181c56…

5. Configure environment for building

Run configure script to configure environment for building:

Refer to screenshot when configure is running:

6. Build Chocolate Doom

Run make command to build image:

Refer to screenshot when make is running.

7. Install Chocolate Doom

Run make install command to install Chocolate Doom:

Refer to screenshot when make install is running

8. Download wad files

Download wad files from webs. For example, from web:

https://www.pc-freak.net/blog/doom-1-doom-2-doom-3-game-wad-files-for-download-playing-doom-on-debian-linux-via-freedoom-open-source-doom-engine/

Refer to screenshot of the webs.

Run wget command to get files:

Refer to screenshot when wget is getting Doom1.WAD:

Refer to screenshot when wget is getting Doom2.WAD:

Refer to screenshot when wget is getting Plutonia.wad:

9. Run Chocolate Doom

Run chocolate-doom:

Refer to screenshot of terminal when chocolate-doom is running:

Refer to screenshot of DOOM:

10. Appendix:

With original source of Chocolate Doom version 3.0.0, we got Segmentation fault when ran it. Refer to screenshot below:

The Segmentation fault happened at the statement “SDL_LowerBlit(screenbuffer, &blit_rect, …)” which is a function of SDL 2.0 (in ”/usr/lib/arm-linux-gnueabihf/libSDL2-2.0.so.0”). Refer to screenshot of ddd:

SDL_LowerBlit(…) was going to bit blit paletted 8-bit screen buffer to 32-bit RGBA buffer but failed. The failure is resulted from wrong setting of descriptor rgbabuffer.