Zig64: very barebones Nintendo 64 ROM in Zig

Howdy! Posted about this yesterday on the Zig subreddit, but I figure it’s worth sharing here, too :slight_smile: Long story short: I managed to get a Zig “hello world” running on a Nintendo 64. As far as I know this is the first public example of Zig on the N64 (I’ve searched pretty hard for “Zig on N64” stuff and haven’t found anything else), but if I’m wrong about that I’d love to stand corrected; the more the merrier!

Anyway, here’s the source repo (on Fossil; Git mirror is WIP): Zig64: Zig Nintendo 64 Demo

And a write-up of the trials and tribulations getting this far entailed: Zig64: Baby Steps

Feedback is very much welcome and encouraged. Next major milestone will be to get something actually on the screen.

35 Likes

Looking forward to following along with your progress!

3 Likes

Is anyone on getting Doom compiled with zig build?

… I hope everyone can see where I’m going with this.

One of the demos here:

2 Likes

A couple new milestones hit since the last post:

Current goals:

  • Print stacktraces on panic
  • Handle hardware exceptions/interrupts

In case you haven’t seen it yet, Using Zig to Provide Stack Traces on Kernel Panic for a Bare Bones Operating System - Andrew Kelley

The post is old an those stdlib interfaces have changed a bunch, but I recently tried to emulate this blog post on my own in a barebones riscv32 OS and was able to get the new stdlib code to bend to my will. Unfortunately I wasn’t able to get it working because of (what I suspect to be) some linking problem, but the general methodology seems still good enough.

3 Likes

Thanks! Andrew’s article was indeed a huge help for the current panic handler stub, and yeah, even panic()'s signature is a little bit different these days, but that’s to be expected considering how much Zig has evolved since then :slight_smile:

What linking problem did you hit? I know the article mentions hitting one when including the DWARF data in the emitted binary, and while it sounds like it was an LLVM bug that should be resolved upstream by now, I wonder if there are similar overzealous restrictions still lurking. I know RISC-V and MIPS are pretty similar in a lot of respects, so I wouldn’t be surprised if snags affecting one might affect the other.