Mupen64Plus Components

#### Supplemental Linux® From Scratch - Version 13.0

### Chapter 21. Video Game Emulators

- Prev

  Introduction to Nintendo 64 Emulation

- Next

  General Gaming Software

- Up
- Home

# Mupen64Plus Components

## Introduction to Mupen64Plus Components

This page will install multiple Mupen64Plus components and plugins, as well as a command-line frontend as a bare necessity. If you do not wish to install a graphical frontend, this page will provide all the parts of Mupen64Plus you will need.

### Note

This may take a while to build. Feel free to do something else while this is building.

- Download: https://github.com/mupen64plus/

### Mupen64Plus Components Dependencies

#### Required

FreeType2, GLU, libpng, OpenGL (libglvnd or Mesa; Mesa's GL is not supported), sdl2-compat, and Vulkan-Loader

#### Recommended

hicolor-icon-theme, libsamplerate, minizip from zlib-1.3.2 (for `.zip` extraction support), NASM, opencv, SDL2_net-2.2.0, and Speex

## Downloading Mupen64Plus Components

First create a list of files to be downloaded:

    cat > m64plus-list << "EOF"
    mupen64plus-core/releases/download/2.6.0/mupen64plus-core-src-2.6.0.tar.gz
    mupen64plus-input-sdl/releases/download/2.6.0/mupen64plus-input-sdl-src-2.6.0.tar.gz
    mupen64plus-audio-sdl/releases/download/2.6.0/mupen64plus-audio-sdl-src-2.6.0.tar.gz
    mupen64plus-rsp-hle/releases/download/2.6.0/mupen64plus-rsp-hle-src-2.6.0.tar.gz
    mupen64plus-video-rice/releases/download/2.6.0/mupen64plus-video-rice-src-2.6.0.tar.gz
    mupen64plus-ui-console/releases/download/2.6.0/mupen64plus-ui-console-src-2.6.0.tar.gz
    EOF

To download the needed files using Wget, use the following commands:

    mkdir m64plus &&
    cd    m64plus &&
    grep -v '^#' ../m64plus-list | wget -i- -c \
        -B https://github.com/mupen64plus/ &&
    wget https://github.com/gonetz/GLideN64/archive/c8ef81c7d9aede9f67f6ed3d3426c90541f9f13e.tar.gz \
        -O GLideN64-c8ef81c7d9aede9f67f6ed3d3426c90541f9f13e.tar.gz

## Installation of Mupen64Plus Components

### Note

When installing multiple packages in a script, the installation needs to be done as the root user. There are three general options that can be used to do this:

1. Run the entire script as the root user (not recommended).

2. Use the sudo command from the sudo package.

3. Use su -c "command arguments" (quotes required) which will ask for the root password for every iteration of the loop.

One way to handle this situation is to create a short bash function that automatically selects the appropriate method. Once the command is set in the environment, it does not need to be set again.

    as_root()
    {
      if   [ $EUID = 0 ];        then $*
      elif [ -x /usr/bin/sudo ]; then sudo $*
      else                            su -c \\"$*\\"
      fi
    }

    export -f as_root

Next, start a subshell that will exit on error:

    bash -e

Install all the packages by running the following commands:

    for package in $(grep -v '^#' ../m64plus-list)
    do
    package=$(basename "$package")
    packagedir=${package%.tar.?z*}
    type=$(echo $package | sed -e 's/mupen64plus-//' -e 's/-src-[0-9].*//')
    echo "Building $packagedir"
      tar -xf $package
      pushd "$packagedir"/projects/unix
      if [ $type == "core" ]; then
        sed -e 's/<zip.h/<minizip\/zip.h/'     \
            -e 's/<unzip.h/<minizip\/unzip.h/' \
            -i ../../src/main/savestates.c
      fi
      make PREFIX=/usr NETPLAY=1 all
      as_root make PREFIX=/usr install
      popd
      rm -rf $packagedir
      as_root /sbin/ldconfig
    done

    tar -xf GLideN64-c8ef81c7d9aede9f67f6ed3d3426c90541f9f13e.tar.gz
    pushd GLideN64-c8ef81c7d9aede9f67f6ed3d3426c90541f9f13e/projects/cmake
      cmake -D CMAKE_INSTALL_PREFIX=/usr \
            -D GL_PROFILE=On             \
            -D MUPENPLUSAPI=On           \
            -D USE_SYSTEM_LIBS=On        \
            -G Ninja ../../src
      ninja
      as_root ninja install
      as_root /sbin/ldconfig
    popd

Finally, exit the shell that was started earlier:

    exit

## Command Explanations

sed -e 's/<zip.h/<minizip\/zip.h/' ...: This command ensures that minizip's `unzip.h` can be found and that minizip's `zip.h` is used, following upstream's change of minizip's pkg-config file so that it no longer specified the proper include path. This change was intentional.

`NETPLAY=1`: This enables netplay support which allows you to play with other people online. Omit this if you have not installed SDL2_net-2.2.0.

`-D GL_PROFILE=On`: This turns on the OpenGL profiling in the GLideN64 plugin.

`-D MUPENPLUSAPI=On`: This parameter forces the build system to build the Mupen64Plus version of the GLideN64 plugin.

`-D USE_SYSTEM_LIBS=On`: This parameter forces the build system to use the system-installed dependencies of the GLideN64 plugin.

## Using Mupen64Plus

From this point, you have a couple of options on how to interact with Mupen64Plus. You can either use mupen64plus, which is the Mupen64Plus command-line frontend, or you can use a graphical frontend such as mupen64plus-ui-python. Graphical frontends generally have many bells and whistles on top of being more user friendly. There are also Mupen64Plus launchers, which instead of using the system-installed Mupen64Plus components, they use their own in-house components/forks. A good launcher is RMG, well-known for being easy to use and set up, but has more and harsher dependencies. The mupen64plus application can work just as well, however. The rest of this section will cover the mupen64plus program.

You can choose which plugins to use, and there are various plugin types. Generally, the plugin name you will pass will be `mupen64plus-`<TYPE>`-`<NAME>``. `<TYPE>` can either be `audio`, `input`, `rsp`, or `video`.

- For `audio`, pass `--audio mupen64plus-audio-`<NAME>``.

- For `input`, pass `--input mupen64plus-input-`<NAME>``.

- For `rsp`, pass `--rsp mupen64plus-rsp-`<NAME>``.

- For `video`, pass `--gfx mupen64plus-video-`<NAME>``.

### Tip

You can find the list of installed plugins in “Contents”.

After passing the plugins you want once, the program will make those plugins the default and will be used for every run of the program after that. It is recommended to pass what you want to the program on the first run, quit out of the program, configure the plugins, then start emulating the ROMs you wish.

## Configuring Mupen64Plus

### Config Files

`~/.config/mupen64plus/mupen64plus.cfg`

### Configuration Information

If you plan to only use mupen64plus, the command-line Mupen64Plus frontend, you will have to configure the options manually. You can generate a default configuration file from simply running mupen64plus once. It will stack all the default configuration files from `/usr/share/mupen64plus` into `~/.config/mupen64plus/mupen64plus.cfg`. It will automatically stack configuration files from the plugins it chooses if you have not passed which plugins you want to use to mupen64plus. If you want to use a different plugin, pass the plugin name to the command, then the program will dump the new defaults to the configuration file if the plugin section is not already there.

Mapping your controller is the most difficult part but becomes a lot easier if you use jstest-sdl-710687. First, connect your controller and invoke `jstest-sdl -l`. You should see a controller listed, perhaps multiple entries. In the case that there are two entries for one controller, and one of them at the end says `(IMU)`, you will want to choose the controller that doesn't list `(IMU)` at the end of the name. Each listing will have a joystick number. If you only have one controller connected, it should be `0`. Once you have decided which JS number you are going to test, run `jstest-sdl -t `<JS>``. You should be brought up to a screen with axis, buttons, hats, and balls listings, and depending on the quality of the sticks, the axis listings may already be moving slightly.

Now go ahead and edit `~/.config/mupen64plus/mupen64plus.cfg` in the `[Input-SDL-Control1]` section for the first controller. Ensure `mode` is equal to `0` so that you can bind the mappings properly. Now edit each field to that which matches your controller's input scheme that appears in jstest-sdl. Once you feel confident in the mappings, save the file and test the inputs by running a ROM. If all went well, the mappings should work. You may have to edit the deadzones, but hopefully the default should work for you.

If you aim to use a graphical frontend, the manual configuration will hopefully not be necessary. Most graphical frontends will handle the configuration for you through the GUI.

## Contents

Installed Programs: mupen64plus
Installed Libraries: libmupen64plus
Installed Plugins: mupen64plus-audio-sdl, mupen64plus-input-sdl, mupen64plus-rsp-hle, mupen64plus-video-GLideN64, and mupen64plus-video-rice
Installed Directories: /usr/include/mupen64plus, /usr/lib/mupen64plus, and /usr/share/mupen64plus

### Short Descriptions

mupen64plus | is the command-line frontend for Mupen64Plus
`libmupen64plus` | is the Mupen64Plus core that can be used by various frontends and loads the necessary plugins

- Prev

  Introduction to Nintendo 64 Emulation

- Next

  General Gaming Software

- Up
- Home