Nintendo Switch port - #272
Conversation
… was not waiting for consumer and it played songs x10 times faster
… to SDLSysSemaphore. Also fixed semaphore leak on destructor
…a project while playing another one
…artifact so it's safe
|
Awesome job mate, Piggy is really perfect for the Switch =D The semaphore change is something I need to have a look at, it was part of the fixes for "audio randomly dying" bug that came back from the dead several times. Cheers! |
|
My pleasure! I loved playing with LGPTracker on my RG35XXH back then, but on Nintendo Switch it's even better, the screen is a true blessing. After using it for 2 days, I can say it's not perfect, but it works! The only problems I found were on latency and loading really long samples. I wanted to chop a 20s amen break and the UI was a bit unresponsive, and the audio renders after 0.3~0.5s but maybe I can tune the buffer settings better. |
Description
This PR adds Nintendo Switch as a build target. The build produces a devkitPro/libnx homebrew
.nrofile, and the homebrew menu (hbmenu) starts it. The PR also adds the release package and two CI jobs.The port uses the existing SDL2 adapters. Most of the new code is the platform adapter in
sources/Adapters/SWITCH/.Two of the defects below affect all platforms.
UnixSysSemaphore. That class callssem_open. On devkitA64,sem_openis an ENOSYS stub that returns NULL, sosem_waitreturned immediately and never blocked. The audio thread then rendered without any limit. Switch now installsSDLProcessFactory, which creates its semaphore withsem_init. No target compiledSDLProcess.cppbefore this PR, so it also needed two corrections: itsSDL_CreateThreadcall used the SDL1 signature, and its destructor leaked the semaphore.onEvent()held theMixerServicelock during the load, andMixerService::Close()destroyed that same mutex. The application now defers the load to the nextonUpdate()call, after it releases the lock.rules_baseused\+in its sed expression.\+is a GNU extension, and BSD sed reads it as a literal+character. The generated.dfiles were malformed on macOS. The expression now uses the POSIX class[[:space:]]*.../../../path, because thatzipcommand was missing the-joption.unziprefuses to extract such paths.SDLGUIWindowImpnow scales the user interface to the full screen when the application does not run in a window. Before, it scaled only when the video driver wasfbcon. The Switch runs full screen but reportsframebuffer_ == false, so it drew the interface at scale 1 in the center of a 720p screen. The new condition only adds a case that other platforms do not reach.Type of change
Feature
Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
How Has This Been Tested?
Test Configuration:
nxlink -sto read the log output. I built on macOS with devkitA64, libnx and switch-sdl2.make PLATFORM=SWITCHinprojects/. Then runnxlink -s lgpt-switch.nro.lgpt_package.shwith the lgpt-resources payload. Extract the package into an empty directory. Then copy theswitchfolder to an SD card that has no previous LGPT installation.Proof pic, running on a Nintendo Switch OLED
Checklist:
sources/Application/Model/Project.h