/Pong-Homebrew-GBA

A simple pong game built for the GBA. Learn about homebrew and game development

Primary LanguageCMIT LicenseMIT

Building Pong for the GBA

gba-sp-homebrew-pong.mp4

This repository provides an example of how to build pong for the Game Boy Advance (GBA). It is built in such a way that it can be ported to other consoles with few changes. It is not meant to win any prizes or be heavily optimized. Rather, it is made to be simple to understand, and an example game that can be used for learning.

When building games and programs for new hardware, or using a new language or framework, building a simple game like pong is one of the best ways to familiarize yourself with the platform. For the same reasons, if you are just getting into game development, or getting into homebrew development for the first time, pong makes an excellent first game to learn the fundamentals. Without much code, building pong teaches you about:

  • User Input
  • Rendering Graphics
  • Collision Detection
  • Designing Game Logic
  • Creating a Points System
  • Computer Players / AI
  • Managing Game States

If the GBA, game dev, homebrew, or any the items above are new to you, hopefully the code in this repo can help you start to familiarize yourself with them. Other uses for this example game include:

  • Practicing ROM Hacking with a small game and source code you can check
  • Testing core functionality for a GBA emulator you're developing
  • Practicing porting a game to other consoles with an easy example

Pong-Homebrew-GBA.mov

This game has a very simple menu that is primarily included to demonstrate switching between game states in a game loop, and to allow the player to choose when they start a new game. It is not meant to show you how to create a proper menu, but I suppose you could modify the code to handle more menu options and sub menus if you wanted.

Additionally, if you want to learn about more advanced game dev features you can extend the game with your own code to:

  • Use sprites and more complex graphics
  • Add a multiplayer mode
  • Add more menus and the ability to edit settings
  • Build a 3D version

This game uses mode 3, one of the bitmap modes for the GBA (3, 4, and 5 are bitmap modes). This is one of the simplest modes to work with, but has its limitations. Updating pixels with the CPU is not particularly fast. For more intense graphics for 2d games, using one of the tile modes is usually a better choice for the GBA. But bitmap modes do have their place. For simple 2d graphics like in this game, or highly dynamic graphics such as those used in 3d games and semi-3d (raycaster) games, bitmap modes are often needed for software rendering. If you do plan on building a graphically intense game in a bitmap mode, keep in mind you'll have to do a fair amount of optimization to get it to run at a good speed. This certainly can be done, and there are impressive ports of Doom, Wolfenstein, and even Tomb Raider to the GBA that use bitmap modes. For our purposes mode 3 will be sufficient.

You can also watch my ▶️ video on getting started building pong for the GBA that links to this repo.

Getting and building the code

First install devkitPro, see https://devkitpro.org/wiki/Getting_Started

Make sure to install the GBA tools for devkitPro. If you are on Windows this is usually done with the devkitPro Installer, whereas if you are using macOS or Linux you'd typically use devkitPro Pacman on the command line. See the link above for details.

If you need any help getting a homebrew dev environment setup, see my guides for macOS, Windows, and Linux.

With devkitPro and the GBA tools installed, you're ready to go.

Clone the project:

git clone https://github.com/ZeroDayArcade/Pong-Homebrew-GBA.git

cd into the project directory:

cd Pong-Homebrew-GBA

Build the project:

make

You should now have a .gba ROM. At this point you can test it with a GBA emulator such as Visual Boy Advance, or test on real hardware with a GBA flashcart on an actual GBA as shown at the top, or using a GBA flashcart with the DS or DS Lite:

IMG_4633 ROM loaded from GBA Flashcart in slot-2 on a Nintendo DS

One modern way to play a homebrew game you create (or encourage others to play it), is by running it on a retro emulation handheld. Any handheld with a GBA emulator should do. Here's an example on an Anbernic RG353PS:

rg353-gba-rom.mp4

This way people can play your game without a flash cartridge, or the need to jailbreak their console (if you're building homebrew for consoles that require that). If your emulation console supports connecting to a TV via HDMI or wireless, that is also a great option, and allows you to easily play on the big screen.

More ZDA Code and Resources:

Interested in gaming, hacking, and homebrew?

Learn Reverse Engineering, Assembly, Code Injection and More:
🎓 zerodayarcade.com/tutorials

More Retro Gaming Handhelds:
Connecting a Game Boy Advance SP to the Internet
Multiplayer Quake 1 on a Nintendo DS vs PC Player: Crossplay
Tutorial - Crossplay Quake on Anbernic RG353PS vs PC
WiFi Penetration Testing with Anbernic Handhelds

Penetration Testing:
Capturing PMKID from a Wireless Router
Cracking Passwords with PMKID
Capturing 4-Way Handshake from WPA/WPA2 Networks
Cracking WPA/WPA2 Passwords with 4-Way Handshake