A Super Mario 64 decompilation, brought to you by a bunch of clever folks.

Related tags

Miscellaneous sm64
Overview

Super Mario 64

  • This repo contains a full decompilation of Super Mario 64 (J), (U), (E), and (SH).
  • Naming and documentation of the source code and data structures are in progress.

It builds the following ROMs:

  • sm64.jp.z64 sha1: 8a20a5c83d6ceb0f0506cfc9fa20d8f438cafe51
  • sm64.us.z64 sha1: 9bef1128717f958171a4afac3ed78ee2bb4e86ce
  • sm64.eu.z64 sha1: 4ac5721683d0e0b6bbb561b58a71740845dceea9
  • sm64.sh.z64 sha1: 3f319ae697533a255a1003d09202379d78d5a2e0

This repo does not include all assets necessary for compiling the ROMs. A prior copy of the game is required to extract the assets.

Quick Start (for Ubuntu)

  1. Install prerequisites: sudo apt install -y build-essential git binutils-mips-linux-gnu python3
  2. Clone the repo from within Linux: git clone https://github.com/n64decomp/sm64.git
  3. Place a Super Mario 64 ROM called baserom.<VERSION>.z64 into the project folder for asset extraction, where VERSION can be us, jp, eu, or sh.
  4. Run make to build. Qualify the version through make VERSION=<VERSION>. Add -j4 to improve build speed (hardware dependent).

Ensure the repo path length does not exceed 255 characters. Long path names result in build errors.

Installation

Windows

Install WSL and a distro of your choice following Windows Subsystem for Linux Installation Guide for Windows 10. We recommend either Debian or Ubuntu 18.04 Linux distributions under WSL. Note: WSL1 does not currently support Ubuntu 20.04.

Next, clone the SM64 repo from within the Linux shell: git clone https://github.com/n64decomp/sm64.git

Then continue following the directions in the Linux installation section below.

Linux

There are 3 steps to set up a working build.

Step 1: Install dependencies

The build system has the following package requirements:

  • binutils-mips
  • capstone
  • pkgconf
  • python3 >= 3.6

Dependency installation instructions for common Linux distros are provided below:

Debian / Ubuntu

To install build dependencies:

sudo apt install -y binutils-mips-linux-gnu build-essential git libcapstone-dev pkgconf python3
Arch Linux

To install build dependencies:

sudo pacman -S base-devel capstone python

Install the following AUR packages:

Other Linux distributions

Most modern Linux distributions should have equivalent packages to the other two listed above. You may have to use a different version of GNU binutils. Listed below are fully compatible binutils distributions with support in the makefile, and examples of distros that offer them:

  • mips64-elf- (Arch AUR)
  • mips-linux-gnu- (Ubuntu and other Debian-based distros)
  • mips64-linux-gnu- (RHEL/CentOS/Fedora)

You may also use Docker to handle installing an image with minimal dependencies.

Step 2: Copy baserom(s) for asset extraction

For each version (jp/us/eu/sh) for which you want to build a ROM, put an existing ROM at ./baserom.<VERSION>.z64 for asset extraction.

Step 3: Build the ROM

Run make to build the ROM (defaults to VERSION=us). Other examples:

make VERSION=jp -j4       # build (J) version instead with 4 jobs
make VERSION=eu COMPARE=0 # build (EU) version but do not compare ROM hashes

Resulting artifacts can be found in the build directory.

The full list of configurable variables are listed below, with the default being the first listed:

  • VERSION: us, jp, eu, sh
  • GRUCODE: f3d_old, f3d_new, f3dex, f3dex2, f3dzex
  • COMPARE: 1 (compare ROM hash), 0 (do not compare ROM hash)
  • NON_MATCHING: Use functionally equivalent C implementations for non-matchings (Currently there aren't any non-matchings, but this will apply to iQue). Also will avoid instances of undefined behavior.
  • CROSS: Cross-compiler tool prefix (Example: mips64-elf-).

macOS

With macOS, you may either use Homebrew or Docker.

Homebrew

Step 1: Install dependencies

Install Homebrew and the following dependencies:

brew update
brew install capstone coreutils make pkg-config tehzz/n64-dev/mips64-elf-binutils

Step 2: Copy baserom(s) for asset extraction

For each version (jp/us/eu/sh) for which you want to build a ROM, put an existing ROM at ./baserom.<VERSION>.z64 for asset extraction.

Step 3: Build the ROM

Use Homebrew's GNU make because the version included with macOS is too old.

gmake VERSION=jp -j4       # build (J) version instead with 4 jobs

Docker Installation

Create Docker image

After installing and starting Docker, create the docker image. This only needs to be done once.

docker build -t sm64 .

Build

To build, mount the local filesystem into the Docker container and build the ROM with docker run sm64 make.

macOS example for (U):
docker run --rm --mount type=bind,source="$(pwd)",destination=/sm64 sm64 make VERSION=us -j4
Linux example for (U):

For a Linux host, Docker needs to be instructed which user should own the output files:

docker run --rm --mount type=bind,source="$(pwd)",destination=/sm64 --user $UID:$GID sm64 make VERSION=us -j4

Resulting artifacts can be found in the build directory.

Project Structure

sm64
├── actors: object behaviors, geo layout, and display lists
├── asm: handwritten assembly code, rom header
│   └── non_matchings: asm for non-matching sections
├── assets: animation and demo data
│   ├── anims: animation data
│   └── demos: demo data
├── bin: C files for ordering display lists and textures
├── build: output directory
├── data: behavior scripts, misc. data
├── doxygen: documentation infrastructure
├── enhancements: example source modifications
├── include: header files
├── levels: level scripts, geo layout, and display lists
├── lib: SDK library code
├── rsp: audio and Fast3D RSP assembly code
├── sound: sequences, sound samples, and sound banks
├── src: C source code for game
│   ├── audio: audio code
│   ├── buffers: stacks, heaps, and task buffers
│   ├── engine: script processing engines and utils
│   ├── game: behaviors and rest of game source
│   ├── goddard: Mario intro screen
│   └── menu: title screen and file, act, and debug level selection menus
├── text: dialog, level names, act names
├── textures: skybox and generic texture data
└── tools: build tools

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Run clang-format on your code to ensure it meets the project's coding standards.

Official Discord: discord.gg/DuYH3Fh

Issues
  • Use array subscripts instead of pointer math where applicable

    Use array subscripts instead of pointer math where applicable

    I noticed that in several places, pointer math was being used instead of array subscripts. This should fix most of those instances. I made sure that the output from compilation was not changed.

    opened by ZLima12 9
  • Mario keeps randomly crouching

    Mario keeps randomly crouching

    For some reason, I cannot make an issue. When I'm playing the PC port, Mario just randomly crouches sometimes when I'm not pressing the crouch key. My crouch key is Left Shift. I am running Super Mario 64 on Windows 10 x64 1909 using GCC 10.2.0.

    opened by BlueStaggo 6
  • Add Docker Support

    Add Docker Support

    This PR ~~blatantly rips off~~ builds upon the groundwork of https://github.com/n64decomp/sm64/pull/24 with the added benefit of having close to normal build times!

    Clean build

    ❯ time docker run --rm --mount type=bind,source=(pwd),destination=/sm64 --user (id -u):(id -g) sm64 make VERSION=us -j12
    ...
    ________________________________________________________
    Executed in   21.93 secs   fish           external
       usr time   93.08 millis  878.00 micros   92.20 millis
       sys time  188.38 millis    0.00 micros  188.38 millis
    
    ❯ sha1sum build/us/sm64.us.z64                                                                                  20:42:13
    9bef1128717f958171a4afac3ed78ee2bb4e86ce  build/us/sm64.us.z64
    

    Cached build

    ❯ time docker run --rm --mount type=bind,source=(pwd),destination=/sm64 --user (id -u):(id -g) sm64 make VERSION=us -j4
    build/us/sm64.us.z64: OK
    ________________________________________________________
    Executed in    3.11 secs   fish           external
       usr time   33.35 millis  1293.00 micros   32.05 millis
       sys time   28.02 millis    0.00 micros   28.02 millis
    

    This is accomplished by setting up the environment in the docker build, but only compiling during a run. As a result it only takes about a second to set up the environment and start compiling, meaning this could be used for development if one really wanted to.

    Also the compiled files/rom are already in the host file system, no need to pull them out of the container.

    processing 
    opened by ahouts 5
  • Added

    Added "extraout" enhancement

    This patch adds some code that prints the current game state (suitable for discord rich presence) and writes some text fitting the current game situation to "message.txt" (suitable for OBS-Studio).

    It also adds a script "extraout.py" that can be used to set Discord Presence like this: ./build/us_pc/sm64.us.f3dex2e | ./extraout.py

    opened by niansa 3
  • Crash report: Whomp's fortress, chomping flowers

    Crash report: Whomp's fortress, chomping flowers

    Sorry I'm not super familiar with git. A pull request probably isn't the right place to report this, but hopefully you'll see it. In the level called whomp's fortress (1star door to the right of the main stairs), there is a crash that happens if you walk past one of the chomping flowers. If the flower wakes up and then you walk away, the entire app crashes and when you reenter the app is outs you at the start screen.

    opened by Kjk89 3
  • Error with andriod port

    Error with andriod port

    This is the error text "Exception in thread "main" java.lang.NoSuchMethodError: No virtual method toPath()Ljava/nio/file/Path; in class Ljava/io/File; or its super classes (declaration of 'java.io.File' appears in /system/framework/core-oj.jar) at com.android.apksigner.ApkSignerTool.sign(ApkSignerTool.java:353) at com.android.apksigner.ApkSignerTool.main(ApkSignerTool.java:83) make: *** [Makefile:1041: build/us_pc/sm64.us.f3dex2e.apk] Error 1 make: *** Deleting file 'build/us_pc/sm64.us.f3dex2e.apk' error: patch failed: Android.mk:16 error: Android.mk: patch does not apply error: patch failed: Makefile:723 error: Makefile: patch does not apply error: patch failed: src/game/behavior_actions.c:43 error: src/game/behavior_actions.c: patch does not apply" How do I fix this?

    opened by aloshTM 2
  • Remove erroneous long double casts from audiofile.cpp

    Remove erroneous long double casts from audiofile.cpp

    Those were added in the process of trying to get the PC port fork to compile on someone's PowerPC machine and are not present in the original libaudiofile source code nor in the audiofile patch in util. As it turned out later, that causes libaudiofile to fail while reading samples from some AIFF files (generally ones that had an INST chunk added to them for looping), in turn causing tabledesign to fail on said files as well. This issue also affects sm64-port, since that uses the same audiofile.cpp.

    opened by fgsfdsfgs 2
  • Replace fixed dialogID in play_dialog_sound to DIALOG_COUNT

    Replace fixed dialogID in play_dialog_sound to DIALOG_COUNT

    This PR replaces the fixed 170 ID inside an if statement in the play_dialog_sound function to the dynamic DIALOG_COUNT definition (from include/dialog_ids.h). This should makes it slightly more easier to add additional dialogs when creating hacks.

    Compare checks are OK'd.

    opened by LittleToonCat 2
  • Fix mips64-binutils for Fedora 31 and similar Linux distros

    Fix mips64-binutils for Fedora 31 and similar Linux distros

    On Fedora the mips64 binutils package has a different naming scheme compared to other Linux distros. The package is called binutils-mips64-linux-gnu.x86_64. My check sees if Fedora's naming scheme is used.

    merged 
    opened by tamara-schmitz 2
  • Added neccessary dependency (capstone) to Quickstart

    Added neccessary dependency (capstone) to Quickstart

    While compiling following the quickstart guide, a capstone.h not found error comes up. This is solved by installing the libcapstone-dev debian/ubuntu package.

    opened by Agvantibo 1
  • use r+b mode for libultra.a patch tool

    use r+b mode for libultra.a patch tool

    no one noticed this one so i will edit the description:

    affects on windows systems but not on unix (linux) since the file is binary, it should use the binary mode too.

    opened by Alto1772 1
  • Update instrument sample names

    Update instrument sample names

    -All instruments with tuning have respective base key in the sample name -A couple sample names were added since their origins have been found (i.e. tabla riffs)

    opened by Trenavix 1
  • Changed apply_patch to use the --merge flag

    Changed apply_patch to use the --merge flag

    This allows users to resolve merge conflicts with patches in code as opposed to generating .rej files. This is probably a preferred behavior as it makes it very clear when patches fail to apply and prevents compilation until merging is resolved, as opposed to the current method which allows compilation even when patches have been partially applied.

    This does not affect the contents of the rom built from this repo.

    opened by Mr-Wiseguy 0
  • Position coin counter from right edge of screen

    Position coin counter from right edge of screen

    Changes the currently fixed X coordinates of the coin counter HUD to use GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE so the counter will be properly right-aligned in widescreen like it is when playing in 4:3.

    opened by nadiaholmquist 10
  • Clarify comment about KtQ speed

    Clarify comment about KtQ speed

    (Chatted about this in #help in the discord about a week ago)

    The original comment confused me when I was examining KtQ code, because it doesn't matter if Mario finishes the race fairly or finishes the race by cheating, only that he has finishes the race. This is what the code is checking for (oKoopaRaceEndpointRaceStatus!=0 matches both "Mario cheated" and "Mario didn't cheat").

    I removed the part about the cannon, since it's implied by finishing the race, and added a line of English to help explain the rest of the conditional

    opened by briandef 0
Releases(irix2)
Owner
Nintendo 64 Decompilation Projects
Nintendo 64 Decompilation Projects
Practice Mod for Super Mario 3D World + Bowsers Fury

Practice Mod This is a mod for Super Mario 3D World + Bowsers Fury that adds different features that intend to aid in speedrun practice (but can also

Fruityloops 4 May 7, 2022
Custom code toolkit for Super Mario Galaxy 2.

Syati Syati is a coding toolkit for custom code injections in Super Mario Galaxy 2. It is able to compile code, link to existing functions and structu

Aurum 5 Jun 24, 2022
Builds atlas texture from a bunch of input images.

Atlasc @septag atlasc is a command-line program that builds atlas texture from a bunch of input images. Main Features Cross-platform. Runs on linux/ma

Sepehr Taghdisian 74 Jun 10, 2022
Flutter app where you can find your information about your Favorite Super Cars ⚡❤

Super Cars App (Flutter) ⚡ Now you can freely discover and browse your Favourite Super Cars ❤ . Speed! ?? Getting Started This project is a starting p

Shehroz Ali 4 Apr 13, 2022
Had a tough time playing Microsoft Wordament ? Well WORDament_Solver has your back. It suggests you meaningful words you can use while playing the game and help you top the leaderboard.

WORDament_Solver Had a tough time playing Microsoft Wordament ? Well WORDament_Solver has your back. It suggests you meaningful words you can use whil

Tushar Agarwal 3 Aug 19, 2021
A decompilation of Banjo Kazooie. (MIRROR of https://gitlab.com/banjo.decomp/banjo-kazooie)

banjo Building Grab tools git submodule update --init --recursive Drop in US v1.0 as baserom.us.v10.z64 (sha1sum: 1fe1632098865f639e22c11b9a81ee8f29c7

Nintendo 64 Decompilation Projects 90 Jun 28, 2022
PaRappa the Rapper Decompilation

PaRappaSource PaRappa the Rapper Decompilation Compiling The instructions for this should largely be the same as PSXFunkin without the iso makes. You

null 12 Jun 10, 2022
Hex-Rays microcode plugin for automated simplification of Windows Kernel decompilation.

NtRays NtRays is a Hex-Rays microcode plugin for automated simplification of Windows Kernel decompilation. Features Cleanup of instrumentation and sch

Can Bölük 324 Jun 23, 2022
An in-progress matching decompilation of Final Fantasy VII For the PSX.

FFVII An in-progress decompilation of the original US release of Final Fantasy VII on the PSX. Building (Linux) Install build dependencies The build p

null 15 Jun 5, 2022
An in-progress decompilation of the 1.1 US release of Silent Hill on the Playstation 1.

Silent Hill Decompilation Project An in-progress decompilation of the 1.1 US release of Silent Hill on the Playstation 1. Building (Linux) Install bui

Nicolas 18 Jun 15, 2022
Ezfrags - Decompilation of the CS:GO cheat ezfrags

Ezfrags Ezfrags was the first cheat of a lot of people, and probably their last. This cheat is so popular that it became a meme in the CS:GO community

null 15 Jun 8, 2022
Decompilation of the Berry Fix Program included in Pokémon Emerald and FireRed/LeafGreen

Berry Fix This is a decompilation of the "Berry Program" multiboot image which comes compressed within Pokémon FireRed, LeafGreen, and Emerald. It is

null 5 Jun 17, 2022
A decompilation of the Nintendo Switch version of Captain Toad: Treasure Tracker [v1.3.0].

cttt-decomp A decompilation of the Nintendo Switch version of Captain Toad: Treasure Tracker [v1.3.0]. Build Instructions Obtain a clean copy of a mai

shibbs 13 May 22, 2022
Mario Kart 7 semi-primary exploit for the Nintendo 3DS.

kartdlphax kartdlphax is a semiprimary exploit for the download play mode of Mario Kart 7. It can be used to run an userland payload in an unmodified

PabloMK7 36 Feb 14, 2022
Extracts and Decompress Mario Sports Mix Files

MSM-File-Converter This is a tool created by TheN00b21 to extract and compress Mario Sports Mix's files. So far it only works with the Menu and Tour f

null 2 Dec 22, 2021
Source code for the Mario Kart Wii Tournament Museum mod

Mario Kart Wii Tournament Museum Source code for the MKWTM mod. Includes the rel source and the loader. Building To compile code you'll need: NXP 'Cod

Puzzle 9 Dec 13, 2021
Super ATX Power!

KCORES-CSPS-to-ATX-Converter 项目视频: 1元10瓦 垃圾佬的超级ATX电源-Youtube KCORES 交流群: 826702309 KCORES 官方网站: KCORES.com 从零开始制作: 入门指南 Specification 12V 5V 3.3V 5VSB

KCORES - 氪金核心 331 Jun 18, 2022
> VSS [ Vairous 7x Super Sploit ] v1.0

Coded By V7x Team # Vairous7x SupperSploit [ VSS v1.0 ] Subscribe to Vairous7x on Youtube For Linux: 1- run 'sudo bash vss-setup.sh' 2- run 'sudo bash

Vairous 7x 30 Jul 5, 2021
Super simple code editor designed for students.

HamroCode Super simple code editor designed for students of Nepal. Language Supported JavaScript C C++ QBASIC Downloading Click Here Demo Created & Ma

Hamro Code 5 Mar 30, 2021