Skip to content
Tr!Force edited this page Nov 19, 2019 · 1 revision

How to build your own games

This is an small guide to start making games for RetroFW (not for beginners). Thanks to Jonathan Holmes (crait#2411) for this guide.

Step 1

Since we're working with Linux-based devices, you're going to need to run Linux. So, if you're on Windows, you'll need to install a Virtual Machine or Cyqwin or something like that. I installed VirtualBox and Xubuntu 18.04. I am terrible with Linux, so I'm not sure how compatible this would be for other Linux

Step 2

The LDK Game uses the RetroFW firmware, so to build games for this firmware, we'll need to install the RetroFW buildroot in your /opt/ folder. The pre-compiled buildroot can be found, here: https://github.com/retrofw/buildroot/releases

Step 3

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

CHAINPREFIX := /opt/mipsel-linux-uclibc
CROSS_COMPILE := $(CHAINPREFIX)/usr/bin/mipsel-linux-

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_RETROGAME
INCLUDES = -Iinclude $(SDL_CFLAGS)
OPT_FLAGS  = -Ofast -fdata-sections -fdata-sections -fno-common -fno-PIC -flto
EXTRA_LDFLAGS = -Wl,--as-needed -Wl,--gc-sections -flto -s

CFLAGS = $(DEFINES) $(INCLUDES) $(OPT_FLAGS) -std=gnu11 
CXXFLAGS = $(DEFINES) $(INCLUDES) $(OPT_FLAGS) -std=gnu++11 
LDFLAGS = $(SDL_LIBS) -lSDL_mixer  -Wl,--start-group -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 4

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

People can make a shortcut and run the game through the Explorer program on the LDK, but, let's talk about a distribution file. To summarize how to make an IPK (the distribution file), do this:

  1. Make a folder path of home/retrofw/ and make a config file called control.
  2. In that folder toss the binaries into the folder as if it was being put onto the actual system, so /games/ - 3. Then compress both, individually, along with a debian-binary file that you need to make, which is a simple text file, then compress that all together with some commands like these:
tar -czvf control.tar.gz control postinst
tar -czvf data.tar.gz home
ar rv MidnightWild.ipk control.tar.gz data.tar.gz debian-binary

This is just a summary, so skim through this document if you are not familiar with this kind of process to fill in the gaps: https://docs.google.com/document/d/19kJXO3EZ8XCoeporuUUgV_S93AaPbSagza3sAgBILu8/edit#heading=h.nihpsh12f0fu

Okay, so, you still have questions, right?

To learn more about the toolchain, you can read through this doc: https://docs.google.com/document/d/19kJXO3EZ8XCoeporuUUgV_S93AaPbSagza3sAgBILu8/edit

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

Random thread that may be worth the read if you have more specialized questions: https://boards.dingoonity.org/ingenic-jz4760-devices/retrofw-developer-support-thread/

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