My GBA Game
An original Game Boy Advance adventure, built one small step at a time.
Play your game
Double-click Build and Play.command in this folder. It builds your ROM, runs the checks, and opens mGBA.
Or open Terminal and run:
cd ~/Developer/pokemon-gba
make play
The game file is game.gba. You can also open it directly in mGBA without rebuilding.
Controls (mGBA defaults)
- Arrow keys: walk and turn to face that direction, including when a wall blocks movement.
- X (GBA A button): talk to Mila, the person in green below the house. Walk close first, then press X again to turn the page and once more to close the conversation. Walking pauses while talking. You can also greet the golden creature when nearby.
- X at the house door: stand on the steps below the door and press X to open it and go inside. Walk to the bottom doorway inside and press X to return outside.
- Leave Greenleaf Village: follow the central sandy path down through the gap in the bottom fence. Keep walking down to enter Sunpetal Trail automatically.
- Return to the village: on Sunpetal Trail, follow the central path up to the top edge. Press X beside the wooden sign to read the directions.
- Visit Professor Mellon: follow the village's horizontal sandy path right through the fence opening. Her blue-roofed house is in the garden. Press X on its steps to enter, then walk close to the professor and press X to talk. Leave through the bottom doorway, then follow the garden path left to return to town.
- Visit Seashell Beach: from Professor Mellon's garden, follow the central sandy path down through the bottom fence gap. Walk up the beach's northern path to return to the garden. Explore the dry sand, palms, umbrella, shells, and starfish; the sea is not walkable. Sprout comes along, and the beach uses the calm trail music.
- Go fishing: talk to Fisher Coral, the red-haired person in turquoise on the right side of Seashell Beach. Press X again to receive a reusable Poké Rod in your bag; choose Save from the Start menu to keep it after restarting. Bring Sprout, walk to the water's edge, face down toward the sea, and press X to hook Tidefin, an original Water-type fish. Weaken it and press Backspace to throw a Poké Ball. Catching still requires balls from Ranger Finn and space on your team. Older saves keep their gifts and catches.
- Get your first partner: talk to Professor Mellon and press X to advance her conversation. She gives you Sprout, an original Grass-type partner at level five. This is a one-time gift; later conversations check on Sprout instead.
- Character artwork: the player and Ranger Finn use boy sprites; Mila and Professor Mellon use distinct long-haired girl sprites. Mellon keeps her white coat and gray hair. Both styles have front, back, and side views.
- Backspace (GBA Select button): open your team. Use Left/Right to browse Sprout and your caught creatures, then press X (A) to choose the displayed creature as your following and battling partner. Backspace or Z (B) returns without changing your choice. Choose Save from the Start menu to retain your selection. Movement pauses while the team screen is open.
- Your partner follows you: Sprout or your selected caught creature follows your path and travels through doors and map exits with you. Each uses its own artwork. Choose Sprout again from the team screen whenever you like.
- Battle the golden creature: with Sprout on your team, walk close to the golden creature in Greenleaf Village and press X. Use Left/Right to choose Tackle or Leaf Tap, then X to attack. The golden creature responds with Bump. Press Z (B) to run away. At the result screen, press X or Z to return to the map. Sprout recovers fully after each battle.
- Wild encounters: with Sprout, walk around either tall-grass patch on Sunpetal Trail. Fernfox (Grass), Emberwing (Fire), or Pebblit (Rock) can appear automatically. Each has its own original 24×24 sprite, palette, health, and attack. Encounters only happen while moving in grass, with a short breather between battles. Leaf Tap is stronger against Pebblit and weaker against Emberwing. Fighting and running use the same keys as the golden-creature battle.
- Get Poké Balls: talk to Ranger Finn, the person in orange just left of Sunpetal Trail's central path. Press X again to receive five Poké Balls. This gift is given once. Press Backspace to see the count on the team screen, even if you do not have Sprout yet.
- Catch a creature: press Backspace during a battle to throw one Poké Ball. Lower health improves the chance; at one-quarter health or less, the catch is guaranteed. A failed throw still uses the ball and lets the creature attack. You cannot catch a fainted creature. Successful catches join your saved team, with room for Sprout plus five catches (duplicates are allowed). A full team does not waste a ball. The village's golden creature disappears from the map once caught. Press X after the catch result, then Backspace and Left/Right to view your new friend. Press X to make it your partner.
- Battle with caught creatures: your selected partner fights in both land and fishing battles, using its own maximum health, Tackle, and a second move: Golden's Bump, Fernfox's Leaf Tap, Emberwing's Spark, Pebblit's Roll, or Tidefin's Water Jet. Partners recover fully after battles. Choose partners outside battle, not during a turn.
- Return (GBA Start button): open the Save / Close right sidebar while exploring. The world stays visible and paused. Up/Down chooses an option, X (A) activates it, and Z (B) or Return closes it. Saved/failed messages wait for a fresh X, Z, or Return press. Start no longer resets your position; the menu cannot open during conversations, battles, or the team screen. Music and S (R) mute continue working while it is open.
- S (GBA R shoulder button): mute or unmute the music, including during battles and menus. This setting lasts until you restart the ROM.
If those keys do not match your emulator settings, check mGBA's keyboard input settings.
Your first change
Open source/actors.c in a text editor. Find:
TEST_INTERNAL const u16 shirt = RGB(5, 14, 29);
Those numbers mean red, green, and blue, each from 0 to 31. Try RGB(29, 6, 6) for a red shirt. Save, then double-click Build and Play.command again.
Project files
source/main.c: GBA hardware, timers, and the main game loop.source/game.h: shared game types and module declarations.source/video.c: frame buffer, dirty rows, text, and sprite renderer.source/scenery.c: map artwork and the scenery cache.source/beach.c: Seashell Beach artwork and shared shoreline boundary.source/world.c: movement, collisions, doors, map travel, and following.source/actors.c: character and creature artwork and drawing.source/battle.c: species, battle rules, and the battle screen.source/story.c: conversations, gifts, and cartridge SRAM saves.source/hud.c: map status, scene drawing, and the team screen.source/menu.c: Save / Close sidebar input and drawing.source/audio.candsource/audio.h: original chiptune scores and the GBA sound-channel sequencer.source/wild_creatures.h: original wild-creature sprites and palettes.source/start.s: code that starts the GBA hardware.gba.ld: tells the compiler where cartridge code and working memory go.tools/rom_header.py: adds the cartridge header the GBA expects.Makefile: builds the game with the installed ARM compiler.tests/: cartridge header, NPC interaction, drawing, house entry/exit, and room collision tests.make checkalso generates scene previews inbuild/.
Run make check-host to check C game behavior on your Mac using only host clang, generating scene previews in build/. It does not need a ROM or the ARM compiler. The C tests are grouped by maps, story, battles, rendering, movement, and audio, with shared helpers in tests/test_support.c. Audio tests use fake sound registers rather than your Mac's audio device. make check builds the ROM, checks its header, runs the ROM-dependent Python tests, and runs these host checks.
Graphics are drawn into a RAM buffer first. Only the changed spans of each row are copied to the GBA screen during VBlank, so walking does not expose a half-erased character. Full map changes are copied while the display is temporarily blanked.
The active map's scenery is cached in a separate 76,800-byte RAM buffer. Walking and dialogue cleanup copy background rows from that cache instead of recalculating every pixel. The cache rebuilds when maps change; opening or closing an exterior door updates only its 13×18-pixel patch. Actors and UI are never stored in the scenery cache.
Sprite artwork is decoded once into cached palette indices. Character and creature bodies are drawn directly in clipped rows, with dirty-region tracking once per source row instead of a rectangle operation per opaque pixel. Mirroring, transparent pixels, dynamic palettes, and scaled battle sprites use the same renderer.
Movement has a separate 60 Hz fixed-step clock using cascaded GBA timers 2 and 3, independent of rendering. Walking is two pixels per tick (120 pixels/second), with normalized diagonal speed. Every pixel is collision-checked and recorded for Sprout and grass encounters, so faster movement does not skip walls or map exits or double the following distance. Missed updates can catch up by at most five ticks; older backlog is dropped after a long stall. Menus, conversations, battles, and map-loading time do not build up movement backlog. The existing footstep artwork is unchanged, with its phase now clocked by simulation ticks rather than rendered frames.
Saving your partner and items
Only choosing Save in the Start sidebar writes cartridge SRAM, stored by mGBA alongside the ROM as game.sav. Gifts, throwing balls (successful or failed, including battle losses), and partner selection change the current session only. Save manually before closing or resetting the emulator; otherwise reload restores your last saved state, including previously unspent balls and unclaimed gifts. Keep game.sav to retain Sprout ownership, Finn's gift flag, remaining balls, the rod, caught species and your selected partner. There are no startup, exit, or gameplay autosaves. Your map, position and battle state are not saved; partners recover after battles.
The sidebar states TEAM AND / ITEMS ONLY / NO LOCATION. GAME / SAVED means the complete v5 cartridge record was written and read back, not that mGBA has flushed it to disk. SAVE / FAILED means validation or read-back failed. Invalid in-memory state is rejected before writing; a read-back failure or interrupted write does not restore the previous record. Close mGBA normally. Existing v1/v2/v3/v4 saves still load; older formats default newly introduced fields appropriately. Save writes the unchanged v5 format. Do not reopen that save with an old v1/v2-only ROM: it cannot load v5 and could overwrite your newer progress.
The ROM uses homebrew game code QST0. The previous FQ01 collided with mGBA 0.10.5's Classic NES detection, which forced EEPROM instead of SRAM.
Music
Three original four-bar chiptunes loop automatically: a bright village tune (112 BPM), a calmer trail/indoor tune (94 BPM), and a faster battle tune (160 BPM). Two hardware square-wave channels play melody and bass, with quiet noise-channel percussion in the village and battle tracks. Menus and conversations keep the current tune playing; entering a battle switches themes, and leaving it restores the location's theme.
The sequencer reads the existing hardware clock without changing the movement timers. It writes sound registers only on note events, uses no PCM audio buffers or audio DMA, and skips missed notes rather than replaying them in a long loop after a stall. These are original melodies, not music copied from Pokémon. In mGBA, make sure emulator audio is unmuted and your Mac's volume is comfortable.
Change what Mila says
Find dialogue in source/story.c. Each pair of strings is one page of her conversation. Use CAPITAL letters and spaces, with no more than 34 characters on each line. Save and rebuild to try your new conversation.
Mac setup
We are using Homebrew's standalone ARM compiler, not devkitPro. The project includes its own minimal startup code and linker script; it does not require devkitPro or an additional GBA library.
-
From the account that owns Homebrew, install the compiler and binary tools:
/opt/homebrew/bin/brew install arm-none-eabi-gcc arm-none-eabi-binutils -
Install mGBA, an emulator for testing our game, either from its website or with:
/opt/homebrew/bin/brew install --cask mgba
Do not run Homebrew with sudo. Homebrew installations and updates should be handled by its owning account. Rory can use the installed compiler to build this project without administrator access.
Never share your Mac password in chat. Enter it only in the Mac's installer or Terminal prompt.
We are making an original game. No existing Pokémon ROM or separate BIOS download is needed for this first project in mGBA.
Project status
Greenleaf Village connects south to Sunpetal Trail and east to Professor Mellon's garden and house. Seashell Beach is south of the garden, with a return path north. Both houses have working doors. Mila and the professor have conversations, and Mellon gives you Sprout once. Ranger Finn gives you five usable Poké Balls. Sprout follows your footsteps and battles the village's golden creature and three wild route species. Battles support two moves, species-specific replies, health bars, catching, victory, defeat, running away, and free recovery. The team screen lets you browse up to six members; use the Start sidebar to save your team and items.
All artwork and music are original; no Pokémon game assets or ROMs are included. Experience, mid-battle partner switching, sound effects, and full progress saving are not implemented yet.