Homebrew Question Mario 64 port?

Gonax

Member
Newcomer
Joined
Oct 14, 2019
Messages
21
Trophies
0
XP
337
Country
United Arab Emirates
Hi, I hope the next steps help to somebody, first forgive my bad English, is no my native language.

Switch Compilation Process

If you read the guide:

https://github.com/fgsfdsfgs/sm64pc/wiki/Compiling-for-Nintendo-Switch

The steps are loosely explained, but they don’t work well for me, so I decided read a lot of documentation and this thread completely.

When you want to compile by yourself the code for Nintendo Switch, you will need have a functional MSYS2 shell, for installing it you need:

Download the latest version from: https://github.com/msys2/msys2-installer/releases

Install the version corresponding to your Operating System (64 or 32 bits).

Accept the defaults in installation program of MSYS2 once you finish the installation you will have shortcuts for MSYS2, MinGW32 and MinGW64. MSYS2 is used to compiling POSIX binaries for Linux from Windows.

MinGW32 & MinGW64 compile Native Windows binaries using a linux toolchain (gcc, bash, etc.)

Launch MSYS2 shell and execute the command: pacman -Syuu several times until you get the message: "there is nothing to do".

In order to compile the Switch binary you must first confirm all works fine compiling a binary for Windows. So do the next steps:

Install prerequisites

In a MinGW64 shell (or MinGW32 if you have a Windows 32 bit edition, why?). Be sure the prompt shows MINGW64 or MINGW32 if not you started the wrong shell, close it and open the right one.

Please execute the next command, several times until you get the message "there is nothing to do", you can be asked to restarts the MINGW64 environment few times:
pacman -Syuu

Then execute the next command:

pacman -Sy --noconfirm base-devel git make mercurial python3 subversion unzip autoconf automake libtool pkg-config autoconf-wrapper mingw-w64-x86_64-cmake mingw-w64-x86_64-gcc mingw-w64-x86_64-glew mingw-w64-x86_64-SDL2 mingw-w64-x86_64-toolchain mingw-w64-x86_64-SDL

Once the installation end, verify the MSYS2 database again:

pacman -Syuu

Clone the repository, using the --recursive option in order to clone all the trees.

git clone --recursive https://github.com/fgsfdsfgs/sm64ex

The repository is cloned to a subfolder of the "Home" directory of MinGWXX Shell, on the prompt "~" means your home directory.

You need copy a legal copy of the original ROM in the cloned directory, it must be in "Big Endian" formatted and called:

./baserom.us.z64

copy the file to the path c:\msys64\home\USERNAME\sm64ex

If your ROM isn't on Big Endian format, use https://hack64.net/tools/swapper.php to convert it.

You should set the $PATH variable. For Windows 64 bits use the command:

export PATH=/mingw64/bin:/mingw32/bin:$PATH

And for Windows 32 bits use:

export PATH=/mingw32/bin:/mingw64/bin:$PATH

The repository needs you to compile the AudioFile library, so you need to run these commands:

Code:
cd sm64ex/tools/audiofile-0.3.6/
autoreconf -i
LIBS=-lstdc++ ; ./configure --disable-docs
make
mkdir ../lib
cp libaudiofile/.libs/libaudiofile.a ../lib/
cp libaudiofile/.libs/libaudiofile.la ../lib/

Then you need to edit the sm64ex\tools\Makefile file using a decent Text Editor and change the line:

tabledesign_CFLAGS := -Wno-uninitialized -laudiofile

By:

tabledesign_CFLAGS := -Wno-uninitialized -laudiofile -lstdc++

Pay attention to the space before " -lstdc++". then run the commands:

Code:
cd ..
make

Last, you can compile the Widows executable using make and the build options you choose, by example:

Code:
cd ..
make BETTERCAMERA=1 NODRAWINGDISTANCE=1 TEXTURE_FIX=1 EXT_OPTIONS_MENU=1 -j9

If all go through you get an .exe file on build subfolder of sm64ex.

Troubleshooting
  • If you get the error gcc: command not found or make: gcc: No such file or directory you do not install all needed packages or run the wrong Shell, be sure of running «MINGW32» or «MINGW64» and what that is pointed on the prompt in purple.
  • If the ROM is missing or wrong format/version you get the error Failed to open baserom.us.z64! Verify the correct ROM at the c:\msys64\home\<username>\sm64ex.folder.
  • If you get the error make: *** No targets specified and no makefile found. Stop. You are on the wrong folder the last make command should be run from c:\msys64\home\<username>\sm64ex folder.
  • Be sure of get the responses Target: i686-w64-mingw32 or Target: x86_64-w64-mingw32 when you run the command gcc -v if else other is shown on screen you install the wrong gcc package or run MSYS shell, remember the process should be run on «MINGW32» or «MINGW64» shells.
Nintendo Switch compilation.

After all works fine and a Windows binary is created, you can run extra steps for make a Switch NRO file

First you need to install DevKitPro.

You need to edit the pacman.conf on c:\msys64\etc\

And add the next lines at end of it:

Code:
[dkp-libs]
Server = https://downloads.devkitpro.org/packages

[dkp-windows]
Server = https://downloads.devkitpro.org/packages/windows

Import the cypher keys of DevKitPro

Code:
pacman-key --recv BC26F752D25B92CE272E0F44F7FD5492264BB9D0 --keyserver keyserver.ubuntu.com
pacman-key --recv F7FD5492264BB9D0

In my case the command fail because the server didn’t send the correct file:
Code:
gpg: keyserver receive failed: General error
==> ERROR: Remote key not fetched correctly from keyserver.

So, I did save the next content on a file called pubring.gpg: ()




Then import it manually:

Code:
pacman-key --import "FULL_PATH_TO_FOLDER_CONTAINING_pubring_gpg"

By example:

Code:
pacman-key --import "C:\downloads\DevKitPro"


Next sign locally the key:

Code:
pacman-key --lsign BC26F752D25B92CE272E0F44F7FD5492264BB9D0
pacman-key --lsign F7FD5492264BB9D0

Then verify the key is working well:

Code:
pacman-key -l BC26F752D25B92CE272E0F44F7FD5492264BB9D0
pacman-key -l F7FD5492264BB9D0

You should get a response just like:

Code:
pub  rsa4096 2018-02-28 [SC]
      BC26F752D25B92CE272E0F44F7FD5492264BB9D0
uid          [  full  ] Dave Murphy (WinterMute) <[email protected]>
sub  rsa4096 2018-02-28 [E]

Install DevKitPro Keyring

Code:
pacman -U https://downloads.devkitpro.org/devkitpro-keyring.pkg.tar.xz

Now verify MSYS2 database:

Code:
pacman -Sy
pacman -Syu

Install DevKitPro packages:

Code:
pacman -S --noconfirm switch-dev devkitA64 dkp-toolchain-vars libnx switch-tools switch-mesa switch-libdrm_nouveau switch-sdl2

Set needed variables

Code:
export DEVKITPRO=/opt/devkitpro
export DEVKITARM=/opt/devkitpro/devkitARM
export DEVKITPPC=/opt/devkitpro/devkitPPC

By last run the next commands in order to make the NRO file, PLEASE DO NOT FORGET TO COPY THE EXE FILE GENERATED FOR WINDOWS TO OTHER PATH, it will be deleted on the next step.

Code:
git stash
git checkout master
git pull
git checkout -f switch
make clean
(optional)
Code:
source $DEVKITPRO/switchvars.sh

You can use any build options you want, one example:

Code:
make TARGET_SWITCH=1 BETTERCAMERA=1 NODRAWINGDISTANCE=1 TEXTURE_FIX=1 -j9

BUILD OPTIONS
Build optionDefaultPossible valuesDescription
VERSIONusus, eu, jp, shWhich ROM to use. The selected ROM has to be in the repo folder with the name baserom.$VERSION.z64. sh is currently broken.
TARGET_BITS32, 64,TARGET_BITS=n appends some compiler flags for an n-bit build. If the value is empty, the option does nothing, assuming your native toolchain will set everything up by itself. Use this only if you're having trouble otherwise.
TARGET_RPI00, 1If 1, select optimal settings for Raspberry PI hardware. See the main article (https://github.com/sm64pc/sm64pc/wiki/Helper-compiling-script-for-Raspberry-Pi) on that.
TARGET_WEB00, 1If 1, build Emscripten version. See the main article (https://github.com/sm64pc/sm64pc/wiki/Compiling-for-the-web) on that.
WINDOWS_BUILD0, 1If 1, build for Windows. Usually set automatically if building on Windows.
OSX_BUILD00, 1If 1, build for OSX.
WINDOWS_CONSOLE00, 1If 1, append -mconsole to Windows CFLAGS, making a console window appear while the game is running. Can be useful for debugging purposes.
DEBUG00, 1If 1, build with debug symbols and default optimization level. Otherwise build with -O2.
RENDER_APIGLGL, GL_LEGACY, D3D11, D3D12Select rendering backend to use.
GL corresponds to OpenGL 2.1 (gfx_opengl.c),
GL_LEGACY corresponds to OpenGL 1.3 (gfx_opengl_legacy.c).
Direct3D backends will also force WINDOW_API to DXGI.
WINDOW_APISDL2SDL2, DXGISelect windowing backend. GL renderers force SDL2 and D3D renderers force DXGI for now, so you don't need to specify this.
AUDIO_APISDL2SDL2Select audio backend. There's only one right now.
CONTROLLER_APISDL2SDL2Specify list of controller backends to use. There's only one right now.
BETTERCAMERA00, 1If 1, build with analog camera support (uses Puppycam).
NODRAWINGDISTANCE00, 1If 1, build with disabled draw distance (every object is active at all times). May affect gameplay.
TEXTURE_FIX00, 1If 1, enable various texture-related bugfixes (e.g. fixes the smoke texture).
EXT_OPTIONS_MENU10, 1If 1, enable Options menu. Accessed from the Pause menu by pressing R.
EXTERNAL_DATA00, 1If 1, load textures and soundbanks from external files. Allows you to use texture packs. The default data is copied to a res folder next to the produced executable. (En Switch va en la carpeta raíz), para PC no lo genera
DISCORDRPC00, 1If 1, enable Discord Rich Presence support. Only works on x86_64.
TEXTSAVES00, 1If 1, use INI-based save format instead of binary EEPROM dumps. Experimental.





Optional Steps
If you want a Banner for the NRO file, you need to put a file called nx_icon.jpg on the sm64ex folder and BEFORE run the last make command you edit the Makefile file and replace the next lines

Code:
# add `--icon=$(APP_ICON)` to this when we get a suitable icon
%.nro: %.stripped %.nacp
      @elf2nro $< $@ --nacp=$*.nacp
      @echo built ... $(notdir $@)

By these:

Code:
# add `--icon=$(APP_ICON)` to this when we get a suitable icon
%.nro: %.stripped %.nacp
      @elf2nro $< $@ --nacp=$*.nacp --icon=$(APP_ICON)
      @echo built ... $(notdir $@)

After the NRO file is created, you can use SAK Switch Army Knife to make a NSP forwarder installable on the HOS.


-edited to update the new packages dependencies-

--edited to correct some typos and code errors--

I manage to build the switch version following you instructions, thank you.
May I ask if there exist a way to play it at 60 fps
 
  • Love
Reactions: impeeza

impeeza

¡Kabito!
Member
Joined
Apr 5, 2011
Messages
6,356
Trophies
3
Age
46
Location
At my chair.
XP
18,696
Country
Colombia
I manage to build the switch version following you instructions, thank you.
May I ask if there exist a way to play it at 60 fps
Yes there is a patch, will post tomorrow
Post automatically merged:

Before build you can apply 60 fps patch, execute the next commands BEFORE make:

Bash:
tools/apply_patch.sh enhancements/60fps_ex.patch
git apply enhancements/60fps_ex.patch

that applies the patch to the source code.

is on the official wiki.
 
Last edited by impeeza,

The_Chaotician

Hoist the Colours!
Member
Joined
Feb 9, 2017
Messages
205
Trophies
0
XP
1,425
Country
United Kingdom
Retrospective from a noob here, now that I have compiled a fully working .nro after the best part of two weeks trying!

First, for anyone using the EXTERNAL_DATA build flag, you must copy the res folder containing the base.zip with the .nro, else the game will crash on boot. May be obvious to anyone who isn’t a noob like me!

@impeeza - thank you so much for the write up on page 17, it holds up perfectly given how long ago it was originally written and has everything you need to know if you have no prior experience in this stuff, thanks again!

Also, a question - What can I put in the res folder that is compatible with this build? I have the Render96 HD texture pack working, but without the models too, the game just looks like N64 era Mario in a modern game?!

I have the .pak texture packs from a previous .nsp installation of NX, but can’t seem to get them to work with my sm64ex build. Any help is gratefully appreciated!

Big thanks to @fgsfds as well for yet another fantastic port! I think I’ve inadvertently collected most if not all of them now!
 

impeeza

¡Kabito!
Member
Joined
Apr 5, 2011
Messages
6,356
Trophies
3
Age
46
Location
At my chair.
XP
18,696
Country
Colombia
Retrospective from a noob here, now that I have compiled a fully working .nro after the best part of two weeks trying!

First, for anyone using the EXTERNAL_DATA build flag, you must copy the res folder containing the base.zip with the .nro, else the game will crash on boot. May be obvious to anyone who isn’t a noob like me!

@impeeza - thank you so much for the write up on page 17, it holds up perfectly given how long ago it was originally written and has everything you need to know if you have no prior experience in this stuff, thanks again!

Also, a question - What can I put in the res folder that is compatible with this build? I have the Render96 HD texture pack working, but without the models too, the game just looks like N64 era Mario in a modern game?!

I have the .pak texture packs from a previous .nsp installation of NX, but can’t seem to get them to work with my sm64ex build. Any help is gratefully appreciated!

Big thanks to @fgsfds as well for yet another fantastic port! I think I’ve inadvertently collected most if not all of them now!
you are welcome, we can ask @kristianity77 to mark as an important post that one (https://gbatemp.net/threads/mario-64-port.564633/post-9149081) for others be able to find it soon.

you can add paks exactil like you do un the PC port.
 
  • Like
Reactions: The_Chaotician

The_Chaotician

Hoist the Colours!
Member
Joined
Feb 9, 2017
Messages
205
Trophies
0
XP
1,425
Country
United Kingdom
Last edited by The_Chaotician,

godreborn

Welcome to the Machine
Member
Joined
Oct 10, 2009
Messages
38,471
Trophies
3
XP
29,138
Country
United States
All I can find online is that “paks are for nx” :(

I put the pak I have in the res folder (with base.zip) next to my .nro but nothing happens… do I need to extract it or convert it?
if those are models, you probably have to compile them with the project. that's how it is with the pc version. btw, there's a packs folder in dynos, but I do not know what a pak file is.
 
  • Love
Reactions: impeeza

The_Chaotician

Hoist the Colours!
Member
Joined
Feb 9, 2017
Messages
205
Trophies
0
XP
1,425
Country
United Kingdom
if those are models, you probably have to compile them with the project. that's how it is with the pc version. btw, there's a packs folder in dynos, but I do not know what a pak file is.
Think it’s an outdated format for textures. There’s a bunch of tools out there to unpack them to turn them into something readable, but none of them work.

I’m guessing you mean drop them in the appropriate folders (e.g. ‘actors’) once the repo is downloaded, prior to running make?
 

godreborn

Welcome to the Machine
Member
Joined
Oct 10, 2009
Messages
38,471
Trophies
3
XP
29,138
Country
United States
Think it’s an outdated format for textures. There’s a bunch of tools out there to unpack them to turn them into something readable, but none of them work.

I’m guessing you mean drop them in the appropriate folders (e.g. ‘actors’) once the repo is downloaded, prior to running make?
well, the render96ex version requires you to compile with the added models, then you can modify the models, but textures just need to be added to the res folder afaik. it could be gfx, but I don't remember. textures don't need to be compiled with them on, at least with render96ex. I may have had a problem recompiling the nx version, but I don't remember if it was a specific version or even that at all. I'm thinking I had some issues with a switch version of something.
 

The_Chaotician

Hoist the Colours!
Member
Joined
Feb 9, 2017
Messages
205
Trophies
0
XP
1,425
Country
United Kingdom
well, the render96ex version requires you to compile with the added models, then you can modify the models, but textures just need to be added to the res folder afaik. it could be gfx, but I don't remember. textures don't need to be compiled with them on, at least with render96ex. I may have had a problem recompiling the nx version, but I don't remember if it was a specific version or even that at all. I'm thinking I had some issues with a switch version of something.
That sounds about right. I managed to compile Render96ex for PC but ran into issues trying to get the Switch version to work. I’ll probably take another stab at it now I know a little bit more about what I’m doing xD

The working file structure is sdmc/switch/sm64/res/gfx so well remembered if it’s been a while since you looked at it :)
 
  • Like
Reactions: godreborn

godreborn

Welcome to the Machine
Member
Joined
Oct 10, 2009
Messages
38,471
Trophies
3
XP
29,138
Country
United States
That sounds about right. I managed to compile Render96ex for PC but ran into issues trying to get the Switch version to work. I’ll probably take another stab at it now I know a little bit more about what I’m doing xD

The working file structure is sdmc/switch/sm64/res/gfx so well remembered if it’s been a while since you looked at it :)
I think it was the nx version, but the render96ex or something mentioned that the switch compile is broken. even if you use the one suggested at the bottom, it doesn't work. however, apparently, it was just a guess as to if it worked. it doesn't with the nx version. I think @impeeza or @binkinator confirmed it. he said he could build it last year, but now it no longer works.
 

impeeza

¡Kabito!
Member
Joined
Apr 5, 2011
Messages
6,356
Trophies
3
Age
46
Location
At my chair.
XP
18,696
Country
Colombia
I think it was the nx version, but the render96ex or something mentioned that the switch compile is broken. even if you use the one suggested at the bottom, it doesn't work. however, apparently, it was just a guess as to if it worked. it doesn't with the nx version. I think @impeeza or @binkinator confirmed it. he said he could build it last year, but now it no longer works.
that's correct.
 

The_Chaotician

Hoist the Colours!
Member
Joined
Feb 9, 2017
Messages
205
Trophies
0
XP
1,425
Country
United Kingdom
Me again,

I’ve made good progress since the last messages. I found some HD models for Mario and Bowser that work very well. I’ve also been playing around with early versions (1.3) of the Render96 model pack to what works and what doesn’t.

The PC version won’t compile, but I attribute that to age and lack of updates. The Switch version compiles and appears to load the models, but…

Errbody Purple!
IMG_2187.jpeg

So two questions, 1) what tf is going on? And 2) what are the options for HD models on fgsfdsfgs fork? My goal is to get it looking as good as the .nsp version of sm64nx if that is at all helpful.

Thanks in advance!
 

Smoker1

Well-Known Member
Member
Joined
Feb 17, 2015
Messages
5,045
Trophies
1
Location
California
XP
6,062
Country
United States
Me again,

I’ve made good progress since the last messages. I found some HD models for Mario and Bowser that work very well. I’ve also been playing around with early versions (1.3) of the Render96 model pack to what works and what doesn’t.

The PC version won’t compile, but I attribute that to age and lack of updates. The Switch version compiles and appears to load the models, but…

Errbody Purple!
View attachment 371551
So two questions, 1) what tf is going on? And 2) what are the options for HD models on fgsfdsfgs fork? My goal is to get it looking as good as the .nsp version of sm64nx if that is at all helpful.

Thanks in advance!
Had that happen one time. Just need to make sure all the HD Textures are in it. Once had a LOT of Purple Items, and Characters. LOL. Just wishing could Compile it into a NSP like those other Builds :(
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    HiradeGirl @ HiradeGirl: Have a nice day. Life. Week. Month. year.