Skip to content

braheezy/ZigGBA

 
 

Repository files navigation

ZigGBA

ZigGBA is an SDK for creating Game Boy Advance games using the Zig programming language. It is currently in a WIP/experimental state. This repository is a maintained fork of wendigojaeger/ZigGBA.

For bug reports and feature requests, please submit a GitHub issue. For general questions and support, you can submit an issue or you can visit the gbadev Discord server which has a #ziggba channel for discussions specifically about this project, as well as other channels for more general discussions about GBA development.

Many thanks to TONC and GBATEK, both of which have been major inspirations and resources for this project.

Usage

The current support Zig version is 0.16.0-dev.1262+be4eaed7c. Get it with zigup 0.16.0-dev.1262+be4eaed7c.

Add to your build.zig.zon:

zig fetch --save git+https://github.com/braheezy/ZigGBA.git

In your build.zig:

const std = @import("std");
// Import ziggba to get access to build helpers
const ziggba = @import("ziggba");

pub fn build(b: *std.Build) void {
  // Create the custom builder.
  const gba_b = ziggba.GbaBuild.create(b);

  // Make a ROM.
  _ = gba_b.addExecutable(.{
      // The output will be 'name.gba'
      .name = "first",
      // The main file to compile.
      .root_source_file = b.path("first.zig"),
  });
}

And a minimal ROM:

// Import the main GBA framework
const gba = @import("gba");

// Required GBA header.
export var header linksection(".gbaheader") = gba.Header.init("FIRST", "AFSE", "00", 0);

// Required exported main function.
pub export fn main() void {
    gba.display.ctrl.* = .initMode3(.{});
    const mode3 = gba.display.getMode3Surface();
    mode3.setPixel(120, 80, .rgb(31, 0, 0));
    mode3.setPixel(136, 80, .rgb(0, 31, 0));
    mode3.setPixel(120, 96, .rgb(0, 0, 31));
}

Fork

This fork has too many changes to document. The highlights are:

  • Integrated Zig build system instead of git submodules
  • Many API rewrites and fixes
  • New core features: interrupts, sound, text

Build Details

ZigGBA's zig build will write example ROMs to zig-out/. These are files with a *.gba extension which can be run on a GBA using special hardware, or which can run in emulators such as mGBA, Mesen, no$gba, and NanoBoyAdvance.

Pass the -Dgdb flag to zig build to also output an *.elf file containing debug symbols.

See the ziggba-example repository for an example of a project which uses ZigGBA as a dependency.

Showcase

First example running on an emulator:

First example emulator image

First example running on real hardware:

First example real hardware image

A whole bunch of examples:

bgAffine

bgAffine.webp

charBlock

charBlock.png

About

Work in progress SDK for creating Game Boy Advance games using Zig programming language.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Zig 97.1%
  • Assembly 2.2%
  • Other 0.7%