Skip to content

[Very WIP] Nintendo Switch homebrew port: feedback only

Shuhao Wu requested to merge shuhao/solarus:switch-1.6.2-rebase into dev

This is a work in progress Nintendo Switch homebrew port of Solarus. The work is based on another port of Solarus 1.5.3 by carstene1ns. I'm sending a merge request for documentation purposes for now as well as gather feedback. To get this ready for merging, a large number of things needs to be done (see list at the end).

To try this, you need an unpatched switch with Atmosphere installed (I'm testing on 0.10.1). You'll need to setup devkitpro and you'll need to compile and install two additional libraries: lua5.1 and physfs. These dependencies are also ported by carstene1ns. I mirrored it to my Github profile in case the source repo goes down. Once these are compiled, one can type make -f Switch.mk in the solarus repo and obtain solarus.nro. This can be placed in the switch/ directory along with data.solarus to launch a game. I'm currently testing ZSDX, with a fork of it available at https://github.com/shuhaowu/zsdx/tree/switch-1.12.2.

ZSDX currently works with OpenGL. Here are the logs from when the game launches:

INFO: Info: Solarus 1.6.2
INFO: Info: Opening quest '.'
INFO: Info: Joypad support enabled: true
INFO: Info: SDL: 2.0.8
INFO: Info: Using modern GL Shaders
INFO: Info: Renderer: GlRenderer
INFO: Info: OpenGL: OpenGL ES 3.2 Mesa 19.0.8
INFO: Info: OpenGL vendor: nouveau
INFO: Info: OpenGL renderer: NV120
INFO: Info: OpenGL shading language: OpenGL ES GLSL ES 3.20
INFO: Info: Quest format: 1.6
INFO: Info: Fullscreen: no
INFO: Info: LuaJIT: no (Lua 5.1)
INFO: Info: Fullscreen: no
INFO: Info: Language: en
INFO: Info: Lua console: no
INFO: Info: Turbo mode: no
INFO: Info: Simulation started

To port Solarus to the Switch, these things were done:

  • Created a new Switch.mk file.
  • Imported mojoAL to replace OpenAL to get audio to work (this was done by carstene1ns).
  • Significantly mess with the joypad handling code as the SDL button IDs of the switch is all scrambled.
    • I had to use some really hacky code to map dpad buttons into joypad hat. This probably should be removed at some point.
  • Mess with QuestFiles.cpp. This was done by carstene1ns and I don't quite understand the code yet due to my unfamiliarity with PHYSFS.

Things that still needs to be done:

  • Rebase this port with master.
  • Figure out how to upstream lua and physfs to devkitpro, or alternatively bring it into the repository like mojoAL.
  • Figure out what to do with the PHYSFS code changes made by carstene1ns.
  • Figure out if a refactor of the joypad handling code is needed. Especially since hero movement is by default mapped to the analog axis and not the dpad.
  • I'm sure other cleanup of the code is required

Merge request reports