Giter VIP home page Giter VIP logo

libsm64's Introduction

libsm64 - Super Mario 64 as a library

The purpose of this project is to provide a clean interface to the movement and rendering code which was reversed from SM64 by the SM64 decompilation project, so that Mario can be dropped in to existing game engines or other systems with minimal effort. This project produces a shared library file containing mostly code from the decompilation project, and loads an official SM64 ROM at runtime to get Mario's texture and animation data, so any project which makes use of this library must ask the user to provide a ROM for asset extraction.

The entire external-facing API of the shared library can be found in libsm64.h. Any client project making use of the library must only include that header and load the library. There's a minimal example project under the test directory as well, demonstrating usage of the library.

Bindings and plugins

Building on Linux

  • Ensure python3 is installed.
  • Ensure the SDL2 and GLEW libraries are installed if you're building the test program (on Ubuntu: libsdl2-dev, libglew-dev).
  • Run make to build. If you want to link musl libc instead of glibc run LIBSM64_MUSL=1 make instead.
  • To run the test program you'll need a SM64 US ROM in the root of the repository with the name baserom.us.z64.

Building on Windows

  • Follow steps 1-4 for setting up MSYS2 MinGW 64 here, but replace the repository URL with https://github.com/libsm64/libsm64.git
  • Ensure the SDL2 and GLEW libraries are installed if you're building the test program.
    • 64 bits: pacman -S mingw-w64-x86_64-SDL2 mingw-w64-x86_64-glew.
    • 32 bits: pacman -S mingw-w64-i686-SDL2 mingw-w64-i686-glew.
  • Run make to build
  • To run the test program you'll need a SM64 US ROM in the root of the repository with the name baserom.us.z64.

Make targets (all platforms)

  • make lib: (Default) Build the dist directory, containing the shared object or DLL and public-facing header.
  • make test: Builds the library dist directory as well as the test program.
  • make run: Build and run the SDL+OpenGL test program.

libsm64's People

Contributors

brawmario avatar headshot2017 avatar heath123 avatar jaburns avatar kafeijao avatar meltyplayer avatar zalo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libsm64's Issues

Add license to project

There should definitely be a license to this project, providing it without one makes it very unclear what can be done with this library without potentially upsetting a contributor. This is especially important if this project is to continue to accept PRs from potential contributors, since it could very quickly become a legal nightmare even if we are all well meaning. The actual Super Mario 64 decompilation project finally settled with the CC0 1.0 license between its contributors last month in this commit: n64decomp/sm64@66018e9 . I'd like to propose the same license for this project too.

Other characters/enemies

Kinda a newbie question here, but can this library be used to add other characters (Yoshi, Luigi, and potentially others from DS version) and/or enemies instead of Mario?

Document difference between core/required functions and extra features

Now that libsm64 has a lot of extra optional functionality it would be nice to specify somewhere what the minimal things to implement are to get Mario running around vs which functions are exposed to make more complex integrations possible. Probably should that info right in the main header with some comments, and then maybe a minimal example usage in the README.

How to build into a .DLL

i know this is kind of a dumb question but how to build the .d and .o files into .dll

(please tell me the ubuntu version, it's easier for me)

Dynamic Surfaces?

Hello!

I've been trying to integrate libsm64 for a project, but I'm running into issues with the key requirement of being able to dynamically swap out the terrain surfaces. It seems that calling the surface init function again locks up Mario, but editing the array that surface init was given a pointer to after the fact similarly accomplishes nothing.

Am I going about this wrong, or are the hacks going to have to be uglier for this to work?

Texture memory mismatch

In main.cpp, the amount of memory you allocate to "texture" is 0x3EE8 bytes (4 * SM64_TEXTURE_WIDTH * SM64_TEXTURE_HEIGHT) , but in load_tex_data.c, the function load_mario_textures_from_rom zeros out 0x2C000 bytes of texture (4 * ATLAS_WIDTH * ATLAS_HEIGHT). That is more than is allocated.

If I'm misunderstanding let me know. Thank you.

Is Sonic Possible?

I am Probably Not smart enough to do this myself, but I felt I should ask anyways.
Is it Possible to do a Similar thing to this with a Decomplication of Sonic Adventure or SADX?
I'm pretty sure that Plenty of people would wanna do the same thing with sonic as they did with this.
So, my only question... Is it even possible?

Fix GCC warnings

The build spits out a fair number of warnings when built with GCC 12.2.0 on linux

Program wont start in blender 3.0

image

i have just downloaded the program and would love to test it out and see what i can do with it

but i cannot use it and i dont know why it wont run for me

i have an unmodded ROM but it still wont work for me

i have the latest version of the program (currently 1.0.5)

i have a powerful PC that should have no trouble running this even in complex scenes

why wont it work ... the instructions say that it should just work and to summarize the instructions: "install addon, find ROM, click 'insert mario' mario will spawn at 3d cursor location

i dont see anywhere that says it wont work and i am frustrated because apparently everyone else seems to get it working but i cant

PC specs below:
Intel i9 9900k @ 4.8ghz
64gb DDR4 RAM @ 3000mhz
RTX 3080Ti 12 gb
2x 2tb HDD @ 7200rpm
2x 1tb HDD @ 7200rpm
1x 1tb SSD @ 512mb/s read write speed samsung 850 evo
1x 1tb M.2 drive @ 1024mb/s read write speed Samsung 970 evo plus
1x 512gb M.2 drive @ 1024 mb/s read write speed Samsung 970 evo plus
windows 10 pro 64bit 20h2

Support for WebAssembly builds

Why? Wasm is neat and could allow porting to platforms where full source mods aren't avaliable but other methods/scripting langs are eg: using Wasynth to compile wasm2luau for robloz

[Minor] Init Buffers Can't Be Validated

The buffers passed to the init function can't be validated to be the correct size. This could cause undefined behavior in a program that passes buffers that are too small.

Null pointer deref when deleting dynamic surface

During the deletion of a dynamic surface it iterates through everything in s_mario_instance_pool.objects however if you delete a mario beforehand there will be gaps in this array which leads to a null pointer deref.

My lazy fix:

diff --git a/src/libsm64.c b/src/libsm64.c
index 1589ffe..b979151 100644
--- a/src/libsm64.c
+++ b/src/libsm64.c
@@ -241,6 +241,7 @@ SM64_LIB_FN void sm64_surface_object_delete( uint32_t objectId )
     // A mario standing on the platform that is being destroyed will have a pointer to freed memory if we don't clear it.
     for( int i = 0; i < s_mario_instance_pool.size; ++i )
     {
+        if (!s_mario_instance_pool.objects[i]) { continue; }
         struct GlobalState *state = ((struct MarioInstance *)s_mario_instance_pool.objects[ i ])->globalState;
         if( state->mgMarioObject->platform == surfaces_object_get_transform_ptr( objectId ))
             state->mgMarioObject->platform = NULL;

Failed to read ROM file "baserom.us.z64" ???

This is getting weird I tried to get the library to use it in Godot but when I attempt to build the shell brings me this
image
I got the US ROM in z64 and renamed it exactly like that baserom.us.z64 and it keeps telling the same error over and over
Here is the root folder:
image
(NOTE: I had to create a folder called run-test because I thought the problem was that the folder doesn't exist)

[Need Help] Integrating into supertux

ok, I want this integrated into supertux(kart)
HOWEVER
I need a screenshare alongside a person aiding mej just to get this to do ANYTHING

  • From the ๐Ÿฑโ€๐Ÿ‘ค

idk what this means help

./import-mario-geo.py
Downloading https://raw.githubusercontent.com/n64decomp/sm64/06ec56df7f951f88da05f468cdcacecba496145a/actors/mario/geo.inc.c
Traceback (most recent call last):
File "/c/users/coolm/documents/libsm64/./import-mario-geo.py", line 99, in
main()
File "/c/users/coolm/documents/libsm64/./import-mario-geo.py", line 64, in main
geo_inc_c = urllib.request.urlopen(GEO_URL).read().decode('utf8')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/urllib/request.py", line 216, in urlopen
return opener.open(url, data, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/urllib/request.py", line 519, in open
response = self._open(req, data)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/urllib/request.py", line 541, in _open
return self._call_chain(self.handle_open, 'unknown',
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/urllib/request.py", line 496, in _call_chain
result = func(*args)
^^^^^^^^^^^
File "/usr/lib/python3.11/urllib/request.py", line 1419, in unknown_open
raise URLError('unknown url type: %s' % type)
urllib.error.URLError:
make: *** [Makefile:45: src/decomp/mario/geo.inc.c] Error 1

help

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.