AnneKitsune/anne_nds_dev
Zig library to compile on Nintendo DS
Provides an easy and convenient way to compile for nds and use functions from DevKitPro.
nix develop
melonDS
emulatorThe .nds file will be in zig-out/bin/name.nds.
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 {...}
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