Libsm64: 将马里奥64作为库供外部游戏引擎使用

Hacker News Top 工具

摘要

Libsm64 提供了超级马里奥64移动和渲染代码的共享库接口,允许开发者将马里奥集成到其他游戏引擎中。它需要一个官方的SM64 ROM来提取资源。

暂无内容
查看原文
查看缓存全文

缓存时间: 2026/07/27 13:44

libsm64/libsm64

来源:https://github.com/libsm64/libsm64

libsm64 - 超级马力欧64 作为库

本项目旨在提供一个简洁的接口,用于调用 SM64 逆向工程项目(https://github.com/n64decomp/sm64)中还原出的移动与渲染代码,使得马力欧能够以最小的改动嵌入到现有游戏引擎或其他系统中。本项目生成一个共享库文件,其中包含大多来自逆向工程项目的代码,并在运行时加载官方 SM64 ROM 以获取马力欧的纹理和动画数据。因此,任何使用此库的项目都必须要求用户提供 ROM 用于资源提取。

共享库的整个外部 API 可以在 libsm64.h 中找到。任何使用此库的客户端项目只需包含该头文件并加载库即可。test 目录下有一个最小示例项目,演示了该库的用法。

绑定与插件

  • Rust 绑定(https://github.com/nickmass/libsm64-rust)
  • Odin 绑定(https://github.com/lammmab/libsm64-odin)
  • Unity 插件(https://github.com/libsm64/libsm64-unity)
  • Blender 插件(https://github.com/libsm64/libsm64-blender)
  • Godot 插件(https://github.com/Brawmario/libsm64-godot)
  • Game Maker 8 扩展(https://github.com/headshot2017/libsm64-gm8)
  • Unity MelonLoader 模组(https://github.com/headshot2017/libsm64-unity-melonloader)
  • Unity BepInEx 插件(https://github.com/sashaantipov2012/libsm64-unity-bepinex)
  • C# 绑定(https://github.com/MeltyPlayer/libsm64-sharp)

在 Mac 和 Linux 上构建

  • 确保已安装 python3。
  • 如果要构建测试程序,请确保安装了 SDL2 和 GLEW 库(在 Ubuntu 上:libsdl2-dev、libglew-dev)。
  • 运行 make 进行构建。如果希望链接 musl libc 而不是 glibc,请运行 LIBSM64_MUSL=1 make。
  • 要运行测试程序,你需要在仓库根目录下有一个名为 baserom.us.z64 的 SM64 美版 ROM。

在 Windows 上构建

  • 按照此链接(https://github.com/sm64-port/sm64-port#windows)中的步骤 1-4 设置 MSYS2 MinGW 64,但将仓库 URL 替换为 https://github.com/libsm64/libsm64.git
  • 如果要构建测试程序,请确保安装了 SDL2 和 GLEW 库。
    • 64 位:pacman -S mingw-w64-x86_64-SDL2 mingw-w64-x86_64-glew。
    • 32 位:pacman -S mingw-w64-i686-SDL2 mingw-w64-i686-glew。
  • 运行 make 进行构建
  • 要运行测试程序,你需要在仓库根目录下有一个名为 baserom.us.z64 的 SM64 美版 ROM。

为 Emscripten(Web)构建(WIP)

运行 emmake make CC=emcc。

如果你希望 libsm64 作为独立模块供 JS 调用(可能没什么用?),则之后运行 emcc dist/libsm64.so -o libsm64.js 来生成 libsm64.wasm 和 libsm64.js。

否则,dist/libsm64.so 应该是一个编译好的 WebAssembly 对象,你可以将其链接到自己的 C 项目中。

Make 目标(所有平台)

  • make lib:(默认)构建 dist 目录,包含共享对象或 DLL 以及公共头文件。
  • make test:构建库的 dist 目录以及测试程序。
  • make run:构建并运行 SDL+OpenGL 测试程序。

相似文章

如何在2026年制作一款Nintendo 64游戏

Hacker News Top

作者详细讲述了他如何将自己的JavaScript游戏引擎移植到C语言,并制作出由Modretro发行的实体N64新游戏Xibalba 64——这是N64主机商业生命周期结束后推出的第二款新游戏。

Can you run every line of code in Super Mario Bros.?

Lobsters Hottest

A speedrunner attempts to execute every byte of the 32KB ROM in Super Mario Bros. using glitches and exploits, covering most of the code including unreachable paths, while documenting the remaining unexecuted bytes.