1
0
Fork
You've already forked zitrus
0
forked from GasInfinity/zitrus
3DS SDK written in Zig
  • Zig 99.9%
GasInfinity 00400a57c1
fix: don't set framebuffers to physical address 0
* I don't know why I even thought this was a good idea,
this is flaky even if it works in hardware and we literally gain
nothing by doing so.
2026年04月20日 18:35:21 +02:00
.forgejo/workflows chore: lock to 0.16.0 + release workflow 2026年04月14日 19:50:03 +02:00
assets feat!: init exefs handling + ns services 2025年09月18日 18:13:09 +02:00
build feat: update to latest zig + 3dsx link implementation 2026年03月14日 17:22:48 +01:00
demo Update remaining demos for zig 0.16.0 2026年04月20日 08:31:04 -05:00
docs chore: lock to 0.16.0 + release workflow 2026年04月14日 19:50:03 +02:00
scripts feat(horizon): add multithreading, new allocator, initial std.Io, ...! 2026年02月13日 20:27:21 +01:00
src fix: don't set framebuffers to physical address 0 2026年04月20日 18:35:21 +02:00
test feat: add mango tests + debug psf renderer + moar 2026年03月26日 18:37:03 +01:00
tools feat: statistic queries + zig fmt 2026年04月19日 12:32:17 +02:00
.gitignore feat(horizon.Io): juice-up the main 2026年02月18日 21:07:31 +01:00
build.zig chore: start the 0.0.0-pre2 release cycle 2026年04月20日 14:34:14 +02:00
build.zig.zon chore: update zigimg, zig and zig-lib fork 2026年04月14日 13:56:41 +02:00
flake.lock feat: type-erased Queue rewrite + CommandBuffer ops + more! 2026年04月17日 15:58:05 +02:00
flake.nix chore: start the 0.0.0-pre2 release cycle 2026年04月20日 14:34:14 +02:00
LICENSE chore: initial commit 2025年06月03日 20:35:43 +02:00
README.md chore: lock to 0.16.0 + release workflow 2026年04月14日 19:50:03 +02:00

Zitrus Logo


Zig support

3DS homebrew sdk written entirely in zig.

Installation

Note

Not even the language this project is written in is 1.0

You acknowledge that any amount of breaking changes may occur until the first stable (minor) release, a.k.a 0.1.0. No ETA is given.

zig fetch --save git+https://codeberg.org/GasInfinity/zitrus

Then add this to your build.zig:

constzitrus=@import("zitrus");constzitrus_dep=b.dependency("zitrus",.{});// zitrus contains code useful for tooling outside of a 3DS environment.constzitrus_mod=zitrus_dep.module("zitrus");constexe=b.addExecutable(.{.name="app.elf",.root_module=b.createModule(.{.root_source_file=b.path("src/main.zig"),.target=b.resolveTargetQuery(.{.cpu_arch=.arm,.os_tag=.@"3ds",}),.optimize=optimize,.imports=&.{.{.name="zitrus",.module=zitrus_mod},},.zig_lib_dir=zitrus_dep.namedLazyPath("juice/zig_lib"),}),});// 3DSX's are PIE'sexe.pie=true;// Needed for any binary which targets the 3DSexe.setLinkerScript(zitrus_dep.namedLazyPath("horizon/ld"));// You can skip installing the elf but it is recommended to keep it for debugging purposesb.installArtifact(exe);constsmdh:zitrus.MakeSmdh=.init(zitrus_dep,.{.settings=b.path("path-to-smdh-settings.zon"),// look at any demo for a quick sample..icon=b.path("path-to-icon.png/jpg/..."),// supported formats depends on zigimg image decoding.});// See `MakeRomFs` if you need something patchable unlike `@embedFile`.// This step will convert your executable to 3dsx (the defacto homebrew executable format) to execute it in an emulator or real 3DSconstfinal_3dsx:zitrus.Make3dsx=.init(zitrus_dep,.{.exe=exe,.smdh=smdh});final_3dsx.install(b,.default);

In your root file, you must also add this, as there's no way to implicitly tell zig to evaluate/import/use it automagically:

pubconststd_os_options:std.Options.OperatingSystem=horizon.default_std_os_options;

Examples / Demos

Currently there are multiple examples in the demo/ directory. To build them, you must have zig 0.16.0 in your path and run zig build.

  • mango contains samples of how to use the mango graphics api.

  • io contains samples of how std.Io may be used.

  • panic is a simple example that panics when opened to test panics and traces.

  • info is a simple app that currently shows the console region and model (will be updated to show more info over time).

  • bitmap is a port of the bitmap example in libctru's 3ds-examples.

  • flappy is a simple fully functional flappy bird clone written entirely with software blitting.

  • gpu is a playground for mango, bleeding edge features are tested there. Not really an example per-se.


You can (and are encouraged) to look at the tools directory as it is a good example of how to use the API's zitrus provides outside (and inside!) of a 3DS environment. Almost all tools are self-contained and span 50-300 LOC.

Coverage

Moved to Coverage

Contributing

Please refrain from using LLMs to make PRs and/or Issues as-is

Currently there's no place to discuss contributions or usage of the SDK, feel free to open an issue if you want to use zitrus but don't know how to start (remember, lack of documentation is also an issue!)

Why

Moved to Why.md

Credits

  • 3dbrew is seriously the best resource if you need info about the 3DS hardware/software.
  • gbatek is the second best resource for low level info about the 3DS hardware.
  • @devkitPro for the tooling, a starting point/reference for this project and reference for unknown/undocumented/unspecified things (e.g: libctru and how tf jumping to home menu worked).
  • @azahar-emu/azahar for providing an emulator to quickly test changes and the initial iterations.
  • @LumaTeam/Luma3DS for literally saving my life when trying to debug things in my 2DS.
  • @TuxSH for his kernel decompilations which allowed (and allow) me to understand more how it works.