Skip to content

Making Games

Tr!Force edited this page Aug 25, 2019 · 40 revisions

How to build your own games

This is an small guide to start making games for Bittboy/PocketGo (not for beginners). Thanks to Crait for this guide and gameblabla for his updates.

Step 1

Since we're working with Linux-based devices, you're going to need to run a Linux distribution. So, if you're on Windows, you'll need to install a Virtual Machine, Cygwin, WSL or something like that.

crait uses Virtualbox along with Xubuntu 18.04 but you can also use mostly any linux distribution as long as it's not too old and that GCC, make and bison are available on it.

I'm using Void linux on my machine myself so most linux distributions should work.

Step 2

The BittBoy uses a custom firmware based around buildroot and Linux.

To compile programs for it, we'll need to get buildroot in order to cross-compile programs for the Bittboy/PocketGo.

There are no prebuilt binaries for the toolchain so it will have to be compiled from source.

Make sure you have the following dependencies : bison, make, gcc.

You will also need at least 10GB of free space before you can proceed.

Run the following commands in a terminal :

git clone https://github.com/bittboy/buildroot.git
cd buildroot
make sdk

Warning : this can take a long time ! (a few hours depending on your machine)

Step 3

Once compiling buildroot is done, go to the "output" folder and then inside of that, go to the "host" folder. Now grab the content of that folder inside and put it in /opt/bittboy-toolchain/.

Note that /opt is usually not writable by normal users so you may need to become root, create the folder and copy it inside.

Step 4

Create a folder for your project with your game's source code and create a makefile for it. Here's the one that crait used for the Midnight Wild game:

CHAINPREFIX= /opt/bittboy-toolchain/
CROSS_COMPILE=$(CHAINPREFIX)/bin/arm-miyoo-linux-musleabi-

CC = $(CROSS_COMPILE)gcc
CXX = $(CROSS_COMPILE)g++
STRIP = $(CROSS_COMPILE)strip
SYSROOT     := $(shell $(CC) --print-sysroot)
SDL_CFLAGS  := $(shell $(SYSROOT)/usr/bin/sdl-config --cflags)
SDL_LIBS    := $(shell $(SYSROOT)/usr/bin/sdl-config --libs)

OUTPUTNAME = midnightwild/midnightwild.elf

DEFINES = -DHAVE_STDINT_H -DVERSION_BITTBOY
INCLUDES = -Iinclude $(SDL_CFLAGS)
OPT_FLAGS  = -Ofast -fdata-sections -fdata-sections -fno-common -fno-PIC -flto
EXTRA_LDFLAGS = -lasound -lmikmod -lmodplug -Wl,--as-needed -Wl,--gc-sections -flto -s

CFLAGS = $(DEFINES) $(INCLUDES) $(OPT_FLAGS) -std=gnu11 
CXXFLAGS = $(DEFINES) $(INCLUDES) $(OPT_FLAGS) -std=gnu++11 
LDFLAGS = -Wl,--start-group -lSDL -lSDL_image -lpng -ljpeg -lSDL_mixer -lfreetype -lSDL_ttf -logg -lvorbisidec -lmikmod -lmodplug -lm -pthread -lz -lstdc++ $(EXTRA_LDFLAGS) -Wl,--end-group

# Redream (main engine)
OBJS =  \
	src/main.o

.c.o:
	$(CC) $(CFLAGS) -c -o $@ $< 

.cpp.o:
	$(CXX) $(CXXFLAGS) -c -o $@ $< 

all: $(OBJS)
	$(CC) -o $(OUTPUTNAME) $(OBJS) $(CFLAGS) $(LDFLAGS)

clean:
	rm -f $(OBJS) $(OUTPUTNAME)

Step 5

Build your software with "make" in the terminal and you should be good to go!

Do you want to find a good example of some source code for the BittBoy? Check out pingflood's IOTester: https://github.com/pingflood/iotester

If you want more support or questions join our Discord chat server here

Clone this wiki locally