No description
Find a file
2026-01-17 11:34:41 -05:00
src export lib 2025-08-07 21:00:21 -04:00
.gitignore init 2025-08-07 18:33:03 -04:00
build.zig bump to 0.2.0 and change signature of compileNds opts. 2026-01-17 11:34:41 -05:00
build.zig.zon bump to 0.2.0 and change signature of compileNds opts. 2026-01-17 11:34:41 -05:00
flake.lock init 2025-08-07 18:33:03 -04:00
flake.nix readme 2025-08-07 18:44:24 -04:00
LICENSE add license. clean zon. 2025-08-07 18:46:54 -04:00
README.md rename to anne_zig_dev for clearer naming scheme 2025-08-08 13:09:21 -04:00

Zig Nintendo DS

Provides an easy and convenient way to compile for nds and use functions from DevKitPro.

  1. Install zig 0.14 / 0.15.
  2. nix develop
  3. zig build # creates a .nds file
  4. zig build run # runs the .nds file in the melonDS emulator

The .nds file will be in zig-out/bin/name.nds.

Adding NDS support to your project

build.zig

const std = @import("std");

pub fn build(b: *std.Build) void {
    const optimize = b.standardOptimizeOption(.{});

    // So that you can call exported functions from anne_nds_dev
    const anne_nds_dev = b.dependency("anne_nds_dev", .{}).module("anne_nds_dev");
    // Creates the module + obj + elf + nds files for you and takes care of the includes/linker arguments.
    const nds_step = @import("anne_nds_dev").compileNds(b, .{
        .root_file = b.path("src/main.zig"),
        .optimize = optimize,
        .name = "nds_test",
        .imports = &.{
            .{
                .name = "nds",
                .module = anne_nds_dev,
            },
        },
    });

    // `zig build` will build for nds.
    b.default_step.dependOn(&nds_step.step);
}

src/main.zig

const nds = @import("nds").nds;
// You need to export a c-style main. Then inside of the main you can call nds' functions.
export fn main(_: c_int, _: [*]const [*:0]const u8) void {...}

Going further

The documentation for libnds, which is what actually does the heavy lifting of communicating with the DS, is available here: https://libnds.devkitpro.org/files.html Several examples are available here: https://github.com/devkitPro/nds-examples

Credits

This work is based on DevKitPro, devkitNix and zig-nds.