Libdragon is an open-source SDK for Nintendo 64. It aims for a complete N64 programming experience while providing programmers with modern approach to programming and debugging. These are the main features:
- Based on modern GCC (11.2) and Newlib, for a full C11 programming experience. A Docker container is available to quickly set up the programming environment.
- The GCC toolchain is 64 bit capable to be able to use the full R4300 capabilities (commercial games and libultra are based on a 32-bit ABI and is not possible to use 64-bit registers and opcodes with it)
- Can be developed with newer-generation emulators (cen64, Ares, Dillonb's n64, m64p) or development cartridges (64drive, EverDrive64).
- Support both vanilla N64 and iQue Player (chinese variant). The support is experimental and done fully at runtime, so it is possible to run ROMs built with libdragon on iQue without modifying the source code.
- In-ROM filesystem implementation for assets. Assets can be loaded with
fopen("rom://asset.dat")
without having to do complex things to link them in. - Efficient interrupt-based timer library (also features a monotone 64-bit timer to avoid dealing with 32-bit overflows)
- Graphics: easy-to-use API for 2D games, accelerated with RDP
- Support for standard N64 controllers and memory paks.
- Support for saving to flashes and EEPROMs (including a mini EEPROM filesystem to simplify serialization of structures).
- Audio: advanced RSP-accelerated library, supporting up to 32 channels and streaming samples from ROM during playback for very low memory usage. Supports WAV files for sound effects and the XM (FastTracker, MilkyTracker, OpenMPT), and YM (Arkos Tracker 2) module formats for background music. Can playback a 10-channel XM with < 3% CPU and < 10% RSP.
- Debugging aids: console (printf goes to screen) exception screen, many
asserts (so that you get a nice error screen instead of a console lockup),
fprintf(stderr)
calls are redirected to your PC console in emulators and to USB via compatible tools (UNFLoader, g64drive). - Support to read/write to SD cards in development kits (64drive, EverDrive64),
simply with
fopen("sd://sdata.dat")
- Simple and powerful Makefile-based build system for your ROMs and assets (n64.mk)
See the libdragon CLI to quickly get libdragon up and running. Basically:
- Download the CLI (as a pre-built binary, or build from source)
- Run
libdragon init
to create a skeleton project - Run
libdragon make
to compile a build a ROM
If you want, you can also compile and run one of the examples that will
be found in libdragon/examples
in the skeleton project.
- Create a directory and copy the
build-toolchain.sh
script there from thetools/
directory. - Read the comments in the build script to see what additional packages are needed.
- Run
./build-toolchain.sh
from the created directory, let it build and install the toolchain. - Install libpng-dev if not already installed.
Below steps can also be executed by running build.sh
at the top level.
- Install libdragon by typing
make install
at the top level. - Install the tools by typing
make tools-install
at the top level. - Install libmikmod for the examples using it. See
build.sh
at the top level for details. - Compile the examples by typing
make examples
at the top level.
You are now ready to run the examples on your N64.
libdragon requires a modern N64 emulator (the first generation of emulators are basically HLE-only and can only play the old commercial games). Suggested emulators for homebrew developemnt are: Ares, cen64, dgb-n64, m64p.
On all the above emulators, you are also able to see in console anything printed
via fprintf(stderr)
, see the debug library for more information.
All cartridges that are able to load custom ROMs should be able to successfully load libdragon ROMs via either USB/serial, or from a MMC/SD card. For instance, the followig are known to work: 64drive, EverDrive64 (all models), SummerCart 64.
If your cartridge has USB support, use one of the loaders that implement the libdragon debugging protocol, so to be able to show logs in console. For instance, UNFLoader, g64drive, ed64. The official loaders provided by the vendors are usually less feature-rich.