https://github.com/tinygo-org/tinygba
Tools and helpers for developing GBA programs using TinyGo.
https://github.com/tinygo-org/tinygba
gameboy-advance golang tinygo
Last synced: 8 days ago
JSON representation
Tools and helpers for developing GBA programs using TinyGo.
- Host: GitHub
- URL: https://github.com/tinygo-org/tinygba
- Owner: tinygo-org
- License: bsd-3-clause
- Created: 2019-12-14T20:59:28.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2023-12-05T14:54:53.000Z (over 2 years ago)
- Last Synced: 2025-08-10T21:34:32.896Z (7 months ago)
- Topics: gameboy-advance, golang, tinygo
- Language: Go
- Homepage: https://tinygo.org
- Size: 72.3 KB
- Stars: 23
- Watchers: 4
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-tinygo - tinygba - Tools and helpers for developing GBA programs using TinyGo. (Gaming / Instrumentation and control with sensors and actuators)
README
# tinygba

Tools and helpers for developing GBA programs using TinyGo.

Still highly experimental and subject to sudden changes.
## Emulator
You can run your TinyGo programs using the `mGBA` emulator:
https://mgba.io/
You will probably need to create a symlink to whichever executable you choose to install. For example, if you install the Qt based emulator:
```shell
sudo ln -s /usr/bin/mgba-qt /usr/bin/mgba
```
## How to use
```go
package main
import (
"machine"
"image/color"
"tinygo.org/x/tinygba"
)
var (
// Colors
black = color.RGBA{}
white = color.RGBA{255, 255, 255, 255}
green = color.RGBA{0, 255, 0, 255}
red = color.RGBA{255, 0, 0, 255}
// Google colors
gBlue = color.RGBA{66, 163, 244, 255}
gRed = color.RGBA{219, 68, 55, 255}
gYellow = color.RGBA{244, 160, 0, 255}
gGreen = color.RGBA{15, 157, 88, 255}
)
func main() {
machine.Display.Configure()
tinygba.FillScreen(black)
for {
tinygba.WaitForVBlank()
update()
}
}
func update() {
key := tinygba.ReadButtons()
switch {
case tinygba.ButtonStart.IsPushed(key):
tinygba.FillScreen(black)
case tinygba.ButtonSelect.IsPushed(key):
tinygba.FillScreen(white)
case tinygba.ButtonRight.IsPushed(key):
tinygba.FillScreen(green)
case tinygba.ButtonLeft.IsPushed(key):
tinygba.FillScreen(red)
case tinygba.ButtonDown.IsPushed(key):
tinygba.FillScreen(gBlue)
case tinygba.ButtonUp.IsPushed(key):
tinygba.FillScreen(gRed)
case tinygba.ButtonA.IsPushed(key):
tinygba.FillScreen(gYellow)
case tinygba.ButtonB.IsPushed(key):
tinygba.FillScreen(gGreen)
}
}
```
Run the code:
```
tinygo run -target gameboy-advance ./examples/snake
```
## Roadmap
- [ ] Display Control (https://problemkaputt.de/gbatek.htm#lcdvramoverview)
- [X] BG Mode 0
- [ ] BG Mode 1
- [ ] BG Mode 2
- [X] BG Mode 3
- [ ] BG Mode 4
- [ ] BG Mode 5
- [ ] OBJ (https://problemkaputt.de/gbatek.htm#lcdobjoverview)
- [ ] Pallettes (https://problemkaputt.de/gbatek.htm#lcdcolorpalettes)
- [ ] Sound (https://problemkaputt.de/gbatek.htm#gbasoundcontroller)
- [ ] Sound Channel 1
- [X] Sound Channel 2
- [ ] Sound Channel 3
- [ ] Sound Channel 4
- [ ] Sound Channel DMA
- [ ] Interrupts (https://problemkaputt.de/gbatek.htm#gbainterruptcontrol)