Libsm64: Mario 64 as a library for use in external game engines
libsm64: Integrating Mario 64 into External Game Engines
The primary objective of this project is to create a streamlined interface for the rendering and movement logic—originally reverse-engineered via the SM64 decompilation project—allowing developers to integrate Mario into various game engines or custom systems with minimal friction.
⚙️ Technical Architecture
The project functions as a shared library. Rather than bundling assets, it extracts textures and animation data from an official SM64 ROM during runtime. Consequently, any application utilizing this library must hardcode assets must require the end-user to provide a valid ROM.
The logic flow can be visualized as follows:
API and Implementation
The entire public-facing API is encapsulated within a single header file: libsm64.h. To implement the library, a client project simply needs to:
- Include the
libsm64.hheader. - Load the compiled shared library.
For those seeking a practical implementation guide, a basic example is provided in the /test directory.
🔌 Supported Bindings & Plugins
The ecosystem for libsm64 is extensive, offering support for various languages and platforms:
- Languages:
RustbindingsOdinbindingsC#bindings
- Engines & Tools:
- Unity: Plugin, MelonLoader mod, and BepInEx plugin.
- Godot: Dedicated add-on.
- Blender: Specialized add-on.
- Game Maker 8: Extension available.
🛠️ Build Instructions
🍎 macOS and 🐧 Linux
To compile on Unix-like systems, follow these requirements:
- Install
python3. - Install
SDL2andGLEW(Required for the test suite).- Ubuntu users:
sudo apt install libsdl2-dev libglew-dev.
- Ubuntu users:
- (Optional) To link
musl libcinstead ofglibc, use the following command:LIBSM64_MUSL=1 make
Note: To execute the test program, place a US SM64 ROM in the root folder named baserom.us.z64.
🪟 Windows
- Setup MSYS2 MinGW 64 (follow steps 1-4 of the standard guide), but use this repository URL:
https://github.com/libsm64/libsm64.git. - Install dependencies via
pacman:pacman -S mingw-w64-x86_64-SDL2 mingw-w64-x86_64-glew - Execute
maketo compile. - Ensure
baserom.us.z64is present in the root directory for testing.
🌐 Web (Emscripten) - Work in Progress
To compile for the web, use:
emmake make CC=emcc
- For a standalone JS call: Run
emcc dist/libsm64.so -o libsm64.jsto generatelibsm64.wasmandlibsm64.js. - For C projects: Use
dist/libsm64.soas a compiled WebAssembly object.
📋 Summary of Make Targets
| Target | Description | Output |
|---|---|---|
make lib | Default build process | dist/ (Shared object/DLL & header) |
make test | Full build including test app | dist/ + Test executable |
🧮 Mathematical Logic
The library essentially treats Mario's state as a function of input and current physics:
📦 Repository Metadata
- License:
CC0-1.0 - Stats:
- ⭐ 861 Stars
- 🍴 50 Forks
- 👀 18 Watchers