Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -419,3 +419,43 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ steps.extract_tag.outputs.tag_name }}
files: projects/*.zip

build-switch:
runs-on: ubuntu-latest
container: devkitpro/devkita64:latest

steps:
- name: Checkout repository
uses: actions/checkout@v4.1.7

- name: Install Switch toolchain deps
run: |
apt-get update && apt-get install -y python3-pil jq
git config --global --add safe.directory "$GITHUB_WORKSPACE"

- name: Build Switch
working-directory: projects
run: make PLATFORM=SWITCH

- name: Package build
working-directory: projects
run: |
TAG=$(curl "https://api.github.com/repos/djdiskmachine/lgpt-resources/tags" | jq -r '.[0].name')
curl -L -o lgpt-resources.zip https://github.com/djdiskmachine/lgpt-resources/archive/refs/tags/${TAG}.zip
unzip lgpt-resources.zip
mv lgpt-resources-${TAG}/*/ ./resources/packaging
rm -rf lgpt-resources*
./resources/packaging/lgpt_package.sh

- name: Extract Git tag name
id: extract_tag
run: echo "tag_name=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
env:
GITHUB_REF: ${{ github.ref }}

- name: Upload build release
uses: softprops/action-gh-release@v2.4.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ steps.extract_tag.outputs.tag_name }}
files: ./projects/*.zip
34 changes: 34 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -408,3 +408,37 @@ jobs:
name: LGPT-${{ github.job }}-${{ github.sha }}.zip
path: projects/*.zip
if-no-files-found: error

switch:
runs-on: ubuntu-latest
container: devkitpro/devkita64:latest

steps:
- name: Checkout repository
uses: actions/checkout@v4.1.7

- name: Install Switch toolchain deps
run: |
apt-get update && apt-get install -y python3-pil jq
git config --global --add safe.directory "$GITHUB_WORKSPACE"

- name: Build Switch
working-directory: projects
run: make PLATFORM=SWITCH

- name: Package build
working-directory: projects
run: |
TAG=$(curl "https://api.github.com/repos/djdiskmachine/lgpt-resources/tags" | jq -r '.[0].name')
curl -L -o lgpt-resources.zip https://github.com/djdiskmachine/lgpt-resources/archive/refs/tags/${TAG}.zip
unzip lgpt-resources.zip
mv lgpt-resources-${TAG}/*/ ./resources/packaging
rm -rf lgpt-resources*
./resources/packaging/lgpt_package.sh

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: LGPT-${{ github.job }}-${{ github.sha }}.zip
path: projects/*.zip
if-no-files-found: error
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ projects/lgpt-bittboy.elf
projects/lgpt-garlic.elf
projects/lgpt-garlicplus.elf
projects/lgpt-rg35xxplus.elf
projects/lgpt-switch.nro
projects/lgpt-switch.nacp
projects/LittleGPTracker.app
projects/LGPT-*.zip
20 changes: 20 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@

1.6.0-bacon18
Migrate W32 to SDL2, removing need for building in vs2008

Nintendo Switch support
* Homebrew .nro built with devkitPro/libnx, launched from hbmenu
* Installs to /switch/lgpt on the SD card, see INSTALL_HOW_TO.txt
* Built on PRs and releases by the CI

Fixes:
Fix songs playing far too fast on Switch
* The audio thread's semaphore came from UnixSysSemaphore, which uses
sem_open - an ENOSYS stub on devkitA64 that returns NULL, so every
wait returned immediately and the thread rendered unthrottled
Fix crash when loading a project while another one is playing
* The load ran while onEvent() held the MixerService lock and
destroyed that very mutex, so the later unlock hit freed memory
Fix dependency file generation on macOS
* The sed in rules_base used the GNU-only \+, which BSD sed takes
literally, leaving the generated .d files malformed
Fix README, CHANGELOG and LICENSE being unextractable from release zips
* They were stored under a literal ../../../ path, which unzip refuses

1.6.0-bacon17
Fix sample list refreshing bug

Expand Down
2 changes: 2 additions & 0 deletions docs/wiki/What-is-LittlePiggyTracker.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ this, set Software rendering **or** change rendering resolution after LGPT has s
- **lgptsav.dat** - this file doesn't exist for new projects but will be created by lgpt when you first save
- **lgpt.fxe** - gp32 executable
- **lgpt.gpe** - gp2x executable
- **lgpt.nro** - Nintendo Switch executable
- **SampleLib** - Place your samples here

Getting lgpt to run depends on your platform:

- **gp32:** place LGPT.fxe, lgptNew, and lgpt10k in \GPMM
- **gp2x/caanoo:** place LGPT.gpe, lgptNew, and lgpt10k in the same folder (anywhere on your SD card)
- **win/mac/\*nix :** everything should be in the right spot, just run the executable in \install\bin\ (for fullscreen run “lgpt.exe -fullscreen”)
- **Nintendo Switch:** merge the `switch` folder from the zip into the root of your SD card, so you end up with lgpt.nro, samplelib and the projects together in /switch/lgpt, then launch it from the homebrew menu. Custom firmware is required, and the folder has to keep the `lgpt` name because the app looks for its projects and samples there.

## Importing Samples

Expand Down
24 changes: 23 additions & 1 deletion projects/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ PSPDIRS := \
../sources/Adapters/SDL/GUI \
../sources/Adapters/SDL/Timer

SWITCHDIRS := \
../sources/Adapters/SWITCH/Main \
../sources/Adapters/SWITCH/System \
../sources/Adapters/Unix/FileSystem \
../sources/Adapters/SDL2/Process \
../sources/System/Process \
$(DUMMYMIDIDIRS) $(SDL2DIRS) $(SDL2AUDIODIRS)

GP32DIRS := .\
../sources/Adapters/GP32FileSystem \
../sources/Adapters/GP32Midi \
Expand Down Expand Up @@ -439,6 +447,20 @@ PSPFILES := \
SDLTimer.o \
PSPSystem.o

SWITCHFILES := \
UnixFileSystem.o \
SwitchMain.o \
SwitchSystem.o \
SwitchNxlink.o \
GUIFactory.o \
SDLGUIWindowImp.o \
SDLEventManager.o \
Process.o \
SDLProcess.o \
SDLTimer.o \
$(SDLAUDIOFILES) \
$(DUMMYMIDIFILES)

#---------------------------------------------------------------------------------
# Windows
#---------------------------------------------------------------------------------
Expand Down Expand Up @@ -520,7 +542,7 @@ $(BUILD):

clean:
@echo clean ...
@rm -fr $(OUTPUT).$(EXTENSION) $(BUILD) *.elf *.gxb *.fxe *.gdb
@rm -fr $(OUTPUT).$(EXTENSION) $(BUILD) *.elf *.gxb *.fxe *.gdb *.nro *.nacp *.map

#---------------------------------------------------------------------------------

Expand Down
77 changes: 77 additions & 0 deletions projects/Makefile.SWITCH
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
-include $(PWD)/rules_base

#---------------------------------------------------------------------------------
# Nintendo Switch (homebrew, devkitPro/libnx)
#---------------------------------------------------------------------------------

ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
endif

# config
DEFINES := \
-DPLATFORM_$(PLATFORM) \
-D_64BIT \
-DBUFFERED \
-DCPP_MEMORY \
-DHAVE_STDINT_H \
-D_NDEBUG \
-DSDL2 \
-DSDLAUDIO \
-DDUMMYMIDI \
-D__SWITCH__

DEVKITARM := $(DEVKITPRO)/devkitA64
TOOLPATH := $(DEVKITARM)/bin
TOOLSBIN := $(DEVKITPRO)/tools/bin
PREFIX := aarch64-none-elf-

# rules_base sets CC/CXX from $(PREFIX) at include time (line 1, above),
# before PREFIX is known here - so bind the real cross-compiler explicitly.
CC := $(PREFIX)gcc
CXX := $(PREFIX)g++
AS := $(PREFIX)as
AR := $(PREFIX)ar
OBJCOPY := $(PREFIX)objcopy

PORTLIBS := $(DEVKITPRO)/portlibs/switch
LIBNX := $(DEVKITPRO)/libnx

# must match the flags libSDL2.a itself was built with (see
# $(PORTLIBS)/lib/pkgconfig/sdl2.pc) or the TLS model / ABI mismatches
ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE -ftls-model=local-exec

SDL_CFLAGS := -I$(PORTLIBS)/include -I$(PORTLIBS)/include/SDL2 -isystem $(LIBNX)/include -D_REENTRANT
# switch-sdl2 uses EGL internally for SDL_GetWindowSurface even though we
# never touch GL ourselves - these are required to satisfy its link deps
SDL_LIBS := -lSDL2 -lEGL -lstdc++ -lglapi -ldrm_nouveau -lnx -lpthread

OPT_FLAGS := -O2 $(ARCH) -ffunction-sections -fdata-sections
INCLUDES := $(SDL_CFLAGS) -I$(PWD)/../sources
CFLAGS := $(DEFINES) $(INCLUDES) $(OPT_FLAGS) -Wall
CXXFLAGS := $(CFLAGS) -std=gnu++03
LIBS := -L$(PORTLIBS)/lib -L$(LIBNX)/lib $(SDL_LIBS)

# <switch.h> (constexpr/alignas) needs C++11; only SwitchNxlink.cpp touches it
SwitchNxlink.o: CXXFLAGS := $(CFLAGS) -std=gnu++11

LDFLAGS := -specs=$(LIBNX)/switch.specs $(ARCH) -Wl,-Map,$(notdir $*.map)

OUTPUT := ../lgpt-switch
EXTENSION := nro

APP_TITLE := LittleGPTracker
APP_AUTHOR := n0s2
APP_VERSION := $(shell awk -F'"' '/PROJECT_NUMBER/{n=$$2} /PROJECT_RELEASE/{r=$$2} /BUILD_COUNT/{b=$$2} END{print n"."r"."b}' $(PWD)/../sources/Application/Model/Project.h)
APP_ICON := $(PWD)/resources/SWITCH/LittleGPTracker.jpg

#---------------------------------------------------------------------------------
# link the elf, then wrap it into a homebrew .nro (with icon/nacp metadata)
#---------------------------------------------------------------------------------

%.elf: $(OFILES)
$(CXX) $(LDFLAGS) -o $@ $(OFILES) $(LIBS)

%.nro: %.elf
$(TOOLSBIN)/nacptool --create "$(APP_TITLE)" "$(APP_AUTHOR)" "$(APP_VERSION)" $(basename $@).nacp
$(TOOLSBIN)/elf2nro $< $@ --icon=$(APP_ICON) --nacp=$(basename $@).nacp
26 changes: 26 additions & 0 deletions projects/resources/SWITCH/INSTALL_HOW_TO.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Installation:
1. You need a Nintendo Switch running custom firmware (Atmosphere) with the
homebrew menu available. Nothing here installs to the HOME menu.
2. Copy the `switch` folder from this zip onto the root of your SD card and
merge it with the one already there. You should end up with:
/switch/lgpt/lgpt.nro
/switch/lgpt/mapping.xml
/switch/lgpt/config.xml
/switch/lgpt/samplelib/
The folder MUST be named `lgpt`: the app looks for its projects and samples
in `sdmc:/switch/lgpt` and will not find them anywhere else.
3. Put the SD card back in the console.


Usage:
Open the homebrew menu (album, or the title override of your choice) and pick
LittleGPTracker. Your projects are saved under /switch/lgpt/.


Notes:
- Audio buffer size and sample rate are already set for this console in the
build. If you add AUDIOBUFFERSIZE, AUDIOPREBUFFERCOUNT, AUDIOSAMPLERATE or
SCREENMULT to config.xml you will override those defaults, which usually
makes things worse (too small a buffer crackles).
- Launching through `nxlink -s lgpt.nro` streams the log output to your PC,
which is useful if you want to report a problem.
Binary file added projects/resources/SWITCH/LittleGPTracker.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions projects/resources/SWITCH/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<CONFIG>
<AUTO_LOAD_LAST value="YES"/> <!-- change to disable auto loading -->
<!-- AUDIOBUFFERSIZE, AUDIOPREBUFFERCOUNT, AUDIOSAMPLERATE and SCREENMULT are
deliberately absent: the Switch values live in SwitchSystem.cpp and
Audio.cpp lets this file override them, so setting them here would undo
the tuned defaults (and SCREENMULT would override the fullscreen
calculation). Only add them if you know you want something different. -->
<KEYDELAY value="200"/>
<KEYREPEAT value="100" />
<FONTTYPE value = '0' /> <!-- '0':original '1':digital '2':monster 'CUSTOM': load custom_font.xml-->
</CONFIG>
14 changes: 14 additions & 0 deletions projects/resources/SWITCH/mapping.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<MAPPINGS>
<MAP src="but:0:0" dst="/event/a" />
<MAP src="but:0:1" dst="/event/b" />
<MAP src="but:0:13" dst="/event/up" />
<MAP src="but:0:15" dst="/event/down" />
<MAP src="but:0:12" dst="/event/left" />
<MAP src="but:0:14" dst="/event/right" />
<MAP src="but:0:6" dst="/event/lshoulder" />
<MAP src="but:0:7" dst="/event/rshoulder" />
<MAP src="but:0:10" dst="/event/start" />
<MAP src="but:0:11" dst="/tempo/tap" />
<MAP src="but:0:8" dst="/mixer/volume/decrease" />
<MAP src="but:0:9" dst="/mixer/volume/increase" />
</MAPPINGS>
26 changes: 21 additions & 5 deletions projects/resources/packaging/lgpt_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,30 @@ collect_resources() { #1PLATFORM #2lgpt.*-exe
elif [ "$1" == "MACOS" ]; then # .app is a folder
zip -9 $PACKAGE -j $CONTENTS
zip -9yr $PACKAGE LittleGPTracker.app/
elif [ "$1" == "SWITCH" ]; then # everything lives in one SD card folder
# hbmenu lists /switch/<dir>/<dir>.nro as a single entry, and the app
# hardcodes sdmc:/switch/lgpt for both bin: and root:, so the binary and
# its data - samplelib and the projects included - all go in that one
# folder. The user merges "switch" into their SD card root.
mkdir -p switch/lgpt ; cp $CONTENTS switch/lgpt
mv switch/lgpt/$2 switch/lgpt/lgpt.nro
cp -r ./resources/packaging/samplelib switch/lgpt
# -type d so the lgpt_* project folders come across as folders, and so it
# doesn't also pick up lgpt_package.sh sitting next to them
find ./resources/packaging -maxdepth 1 -type d -name "lgpt_*" -exec cp -r {} switch/lgpt \;
zip -9 -r $PACKAGE switch/ && rm -r switch/
else # all the others go in the bin
mkdir bin ; cp $CONTENTS bin
zip -9 $PACKAGE bin/* && rm -r bin/
fi
cd ./resources/packaging
CONTENTS="../../../README.md ../../../CHANGELOG ../../../LICENSE"
CONTENTS+=" $(find . -name "samplelib" -type d)"
CONTENTS+=" $(find . -name "lgpt_*" -type d)"
zip -9 -r ../../$PACKAGE $CONTENTS
cd ./resources/packaging
# -j or these get stored as literal ../../../README.md, which unzip refuses
zip -9 -jq ../../$PACKAGE ../../../README.md ../../../CHANGELOG ../../../LICENSE
if [ "$1" != "SWITCH" ]; then # already staged inside switch/lgpt above
CONTENTS="$(find . -name "samplelib" -type d)"
CONTENTS+=" $(find . -name "lgpt_*" -type d)"
zip -9 -r ../../$PACKAGE $CONTENTS
fi
CONTENTS="../../../docs/wiki/What-is-LittlePiggyTracker.md"
CONTENTS+=" ../../../docs/wiki/config_xml.md"
CONTENTS+=" ../../../docs/wiki/tips_and_tricks.md"
Expand All @@ -54,6 +69,7 @@ collect_resources CHIP lgpt.chip-exe
collect_resources BITTBOY lgpt-bittboy.elf
collect_resources GARLICPLUS lgpt-garlicplus.elf
collect_resources RG35XXPLUS lgpt-rg35xxplus.elf
collect_resources SWITCH lgpt-switch.nro
collect_resources MACOS LittleGPTracker.app
# collect_resources RS97 lgpt.dge
# collect_resources STEAM lgpt.steam-exe
2 changes: 1 addition & 1 deletion projects/rules_base
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export OBJCOPY := $(PREFIX)objcopy

define adjustdepends
cp $(DEPSDIR)/$*.d $(DEPSDIR)/$*.P;
sed -e 's/#.*//' -e 's/^[^:]*: \+//' -e 's/^ *//' -e 's/ *\\$$//' -e '/^$$/ d' -e 's/$$/ :/' < $(DEPSDIR)/$*.P >> $(DEPSDIR)/$*.d;
sed -e 's/#.*//' -e 's/^[^:]*:[[:space:]]*//' -e 's/^ *//' -e 's/ *\\$$//' -e '/^$$/ d' -e 's/$$/ :/' < $(DEPSDIR)/$*.P >> $(DEPSDIR)/$*.d;
rm $(DEPSDIR)/$*.P
endef

Expand Down
Loading
Loading