Skip to content

tristanpenman/n64-heart-rust

Repository files navigation

N64 💛 Rust

This repo contains code for a talk given at the Melbourne Rust Meetup, on using Rust on the Nintendo 64. The examples demonstrate various ways that Rust can be used to program the Nintendo 64.

If you would like to see the slides from the talk, these can be found in slides.pdf.

Examples

  1. Old School C
  2. Calling Rust from C
  3. Booting from Rust
  4. Graphics in Rust
  5. Libdragon in C
  6. Libdragon in Rust - Incomplete
  7. More Graphics in Rust - Incomplete

Old School C

When working with something like the Nintendo 64, it helps to a frame of reference. As a starting point, 01-old-school-c provides the basic structure for a game written in C. It can be compiled with both legacy and modern SDKs, and includes minimal 3D graphics.

Calling Rust from C

The next example, 02-calling-rust-from-c, takes a small step towards using Rust, by calling Rust from C. This would allow you to write your game logic in Rust, but continue to rely on C to access SDK functionality.

This example is based on MrPeanut's N64-Rust-Sample repo.

Booting from Rust

Going a step further, 03-booting-rust looks at how we can build an entire ROM using Rust and Cargo. This completely bypasses the Nintendo 64 SDK, and interfaces with the hardware directly. This is essentially OS development on the N64.

This example is based on Jay Oster's rrt0 repo.

Graphics in Rust

The 04-graphics-in-rust shows how Rust can be used to display simple text and full-screen images.

This example is an adaptation of Tristan Miller's n64-slides-apr, rs64-periph and rs64-rt repos, incorporating minor changes from rrt0.

Libdragon in C

This is another example that serves as a reference point. This time we use libdragon, an open source alternative to the official SDK. 05-libdragon-in-c provides a small example that shows how Libdragon works in C.

Libdragon in Rust

NOTE: This example is incomplete.

The aim of the next example, 06-libdragon-in-rust, is to show how we can use Libdragon from Rust, using Rust bindings to the Libdragon library.

More Graphics In Rust

NOTE: This example is incomplete.

The aim of the final example is to show how Rust can be used for 3D graphics.

Tools

  1. Texture Converter

Texture Converter

A small tool for converting images from PNG to RGBA5551 format, appropriate for use with the N64.

Notes

Various notes about Nintendo 64 architecture and development can be found in the notes directory.

References

Websites

Emulators

  • cen64
    • Cycle-accurate N64 emulator, recommended for development
  • Project64
    • N64 emulator for Windows
    • Excellent debugging support
  • sixtyforce
    • Propietary macOS-based emulator
    • High performance and convenient for quick testing

Discord

Interesting N64-related repositories on GitHub

  • Libdragon
    • Libdragon is an open-source SDK for Nintendo 64
    • trunk is stable code
    • unstable contains many new features such as OpenGL 1.1 support
      • Not well-supported by emulators at this stage
    • Not always supported by emalators, due to issues with high level emulation
      • spritemap example at least runs on cen64 and real hardware, so that makes it possible to make a playable game
  • asterois64
    • This is my clone of Asteroids for the Nintendo 64, written in C
    • Uses official SDK
    • Compiles using legacy and modern toolchains

Interesting Rust-specific repositories on GitHub

  • n64-slides-apr
    • Minimal Rust application that presents slides on N64
      • Most slides contain basic text
      • Some slides contain full images
    • Dependencies:
    • Makefile builds elf, then extras object using mips-unknown-elf-objcopy
      • fs.bin for assets
      • combined with IPL boot code using rs64romtool
  • n64-systemtest
    • A comprehensive system test written in Rust
    • Works on real hardware
      • Also tested on cen64, but does not work there
  • cargo-n64
    • A cargo subcommand to build Nintendo 64 ROMs in Rust
    • This is what I used for my examples
  • nust64
    • Intended as a Cargo runner, but may also be used as a library
    • Not sure what the advantage of this over cargo-n64 is
  • libdragon-bindings
    • Rust bindings and interface to the N64-dev library LibDragon
    • Couldn't get it to compile
    • Two years old at this point, and can't seem to find any examples online...
  • rrt0
    • Minimal Rust runtime, with a MIPS assembly entry point for N64

License

The examples in this repo are licensed under the MIT License.

See the LICENSE file for more information.

About

Content for a talk on using Rust on the Nintendo 64

Topics

Resources

License

Stars

Watchers

Forks

Languages