diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fe6d01b30..8683af1f1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -6,7 +6,6 @@ on: push: branches: - main - - build-in-ci pull_request: {} permissions: diff --git a/.github/workflows/dev.yaml b/.github/workflows/dev.yaml new file mode 100644 index 000000000..2af03ca94 --- /dev/null +++ b/.github/workflows/dev.yaml @@ -0,0 +1,56 @@ +--- +name: Development/Desktop + +# yamllint disable-line rule:truthy +on: + push: + branches: + - main + pull_request: {} + +permissions: + attestations: write + contents: read + id-token: write + +jobs: + build-macos: + runs-on: macos-latest + env: + PLATFORM: desktop + + steps: + - name: Checkout + uses: actions/checkout@v4.2.2 + + - name: Install dependencies + run: | + brew install make sdl2_image sdl2_ttf libzip libsamplerate + sudo ./workspace/desktop/macos_create_gcc_symlinks.sh + + - name: Setup + run: make setup + + - name: Build + run: make common PLATFORM=${{ env.PLATFORM }} + + build-linux: + runs-on: ubuntu-24.04-arm + env: + PLATFORM: desktop + + steps: + - name: Checkout + uses: actions/checkout@v4.2.2 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y libsdl2-image-dev libsdl2-ttf-dev + sudo apt-get install -y libzip-dev liblzma-dev libzstd-dev libbz2-dev zlib1g-dev + + - name: Setup + run: make setup + + - name: Build + run: make common PLATFORM=${{ env.PLATFORM }} diff --git a/.vscode/launch.json b/.vscode/launch.json index 9cef4e3eb..e739daf1b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,15 +5,14 @@ "version": "0.2.0", "configurations": [ { - "name": "NextUI Launcher", + "name": "NextUI", "request": "launch", "type": "cppdbg", "osx": { "MIMode": "lldb" }, - "cwd": "${workspaceFolder}/workspace/all/nextui/build/macos", - "program": "${workspaceFolder}/workspace/all/nextui/build/macos/nextui", - "preLaunchTask": "C/C++: gcc build macos", + "cwd": "${workspaceFolder}/workspace/all/nextui/build/desktop", + "program": "${workspaceFolder}/workspace/all/nextui/build/desktop/nextui.elf", "environment": [{ "name": "SHARED_USERDATA_PATH", "value": "/Library/Developer/Projects/private/MinUI_FAKESD/.userdata/shared", @@ -26,9 +25,9 @@ "osx": { "MIMode": "lldb" }, - "cwd": "${workspaceFolder}/workspace/all/battery/build/macos", - "program": "${workspaceFolder}/workspace/all/battery/build/macos/battery", - "preLaunchTask": "C/C++: gcc build macos - Battery", + "cwd": "${workspaceFolder}/workspace/all/battery/build/desktop", + "program": "${workspaceFolder}/workspace/all/battery/build/desktop/battery.elf", + "preLaunchTask": "make desktop", }, { "name": "App: Input", @@ -37,9 +36,9 @@ "osx": { "MIMode": "lldb" }, - "cwd": "${workspaceFolder}/workspace/all/minput/build/macos", - "program": "${workspaceFolder}/workspace/all/minput/build/macos/minput", - "preLaunchTask": "C/C++: gcc build macos - Minput", + "cwd": "${workspaceFolder}/workspace/all/minput/build/desktop", + "program": "${workspaceFolder}/workspace/all/minput/build/desktop/minput.elf", + "preLaunchTask": "make desktop", }, { "name": "App: Gametime", @@ -48,9 +47,9 @@ "osx": { "MIMode": "lldb" }, - "cwd": "${workspaceFolder}/workspace/all/gametime/build/macos", - "program": "${workspaceFolder}/workspace/all/gametime/build/macos/gametime", - "preLaunchTask": "C/C++: gcc build macos - Gametime", + "cwd": "${workspaceFolder}/workspace/all/gametime/build/desktop", + "program": "${workspaceFolder}/workspace/all/gametime/build/desktop/gametime.elf", + "preLaunchTask": "make desktop", }, { "name": "App: Gametimectl", @@ -59,10 +58,10 @@ "osx": { "MIMode": "lldb" }, - "cwd": "${workspaceFolder}/workspace/all/gametimectl/build/macos", - "program": "${workspaceFolder}/workspace/all/gametimectl/build/macos/gametimectl", + "cwd": "${workspaceFolder}/workspace/all/gametimectl/build/desktop", + "program": "${workspaceFolder}/workspace/all/gametimectl/build/desktop/gametimectl.elf", + "preLaunchTask": "make desktop", "args": ["start", "foo.txt"], - "preLaunchTask": "C/C++: gcc build macos - Gametimectl", }, { "name": "App: Settings", @@ -71,13 +70,31 @@ "osx": { "MIMode": "lldb" }, - "cwd": "${workspaceFolder}/workspace/all/settings/build/macos", - "program": "${workspaceFolder}/workspace/all/settings/build/macos/settings", - "preLaunchTask": "C/C++: gcc build macos - Settings", + "cwd": "${workspaceFolder}/workspace/all/settings/build/desktop", + "program": "${workspaceFolder}/workspace/all/settings/build/desktop/settings.elf", + "preLaunchTask": "make desktop", "environment": [{ "name": "SHARED_USERDATA_PATH", "value": "/Library/Developer/Projects/private/MinUI_FAKESD/.userdata/shared", }] - } + }, + { + "name": "Minarch", + "request": "launch", + "type": "cppdbg", + "osx": { + "MIMode": "lldb" + }, + "cwd": "${workspaceFolder}/workspace/all/minarch/build/desktop", + "program": "${workspaceFolder}/workspace/all/minarch/build/desktop/minarch.elf", + "environment": [{ + "name": "SHARED_USERDATA_PATH", + "value": "/Library/Developer/Projects/private/MinUI_FAKESD/.userdata/shared", + }], + "args": [ + "/Library/Developer/Projects/private/MinUI_ro8inmorgan/workspace/desktop/cores/output/gambatte_libretro.so", + "/Library/Developer/Projects/private/MinUI_FAKESD/Roms/Game Boy Color (GBC)/Tetris DX (SGB Enhanced) (GB Compatible).zip" + ], + }, ] } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 0360986a0..548b51a16 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,243 +1,15 @@ { + "version": "2.0.0", "tasks": [ { - "type": "cppbuild", - "label": "C/C++: gcc build macos", - "command": "/usr/bin/gcc", - "args": [ - "-g", "nextui.c", "-o", "${workspaceFolder}/workspace/all/nextui/build/macos/nextui", - "-I.", "-I../common/", "-I../../macos/platform/", "-I/opt/homebrew/include", - "-L/opt/homebrew/lib", - "../common/scaler.c", "../common/utils.c", "../common/api.c", "../common/config.c", "../../macos/platform/platform.c", - "-fomit-frame-pointer", - "-DPLATFORM=\\\"macos\\\"", - "-DUSE_SDL2", "-DUSE_GL", - //"-Ofast", - "-std=gnu99", "-ldl", "-flto", - "-lSDL2", "-lSDL2_image", "-lSDL2_ttf", "-lpthread", "-framework", "OpenGL", "-lm", "-lz", - //"-fsanitize=address", - "-fno-common", - "-Wno-tautological-constant-out-of-range-compare", - "-Wno-asm-operand-widths", - "-Wno-deprecated-declarations" - ], - "options": { - "cwd": "${workspaceFolder}/workspace/all/nextui" - }, - "problemMatcher": [ - "$gcc" - ], - "group": { - "kind": "build", - "isDefault": true - }, - }, - { - "type": "cppbuild", - "label": "C/C++: gcc build macos - Battery", - "command": "/usr/bin/gcc", - "args": [ - "-g", "battery.c", "-o", "${workspaceFolder}/workspace/all/battery/build/macos/battery", - "-I.", "-I../common/", "-I../../macos/platform/", "-I/opt/homebrew/include", "-I../libbatmondb/", - "-L/opt/homebrew/lib", - "../common/scaler.c", "../common/utils.c", "../common/api.c", "../common/config.c", "../libbatmondb/batmondb.c", "../../macos/platform/platform.c", - "-fomit-frame-pointer", - "-DPLATFORM=\\\"macos\\\"", - "-DUSE_SDL2", "-DUSE_GL", - "-DDEBUG", - //"-Ofast", - "-std=gnu99", "-ldl", "-flto", - "-lSDL2", "-lSDL2_image", "-lSDL2_ttf", "-lpthread", "-lsqlite3", "-framework", "OpenGL", "-lm", "-lz", - //"-fsanitize=address", - "-fno-common", - "-Wno-tautological-constant-out-of-range-compare", - "-Wno-asm-operand-widths", - "-Wno-deprecated-declarations" - ], - "options": { - "cwd": "${workspaceFolder}/workspace/all/battery" - }, - "problemMatcher": [ - "$gcc" - ], - "group": { - "kind": "build", - "isDefault": true - }, - }, - { - "type": "cppbuild", - "label": "C/C++: gcc build macos - Minput", - "command": "/usr/bin/gcc", - "args": [ - "-g", "minput.c", "-o", "${workspaceFolder}/workspace/all/minput/build/macos/minput", - "-I.", "-I../common/", "-I../../macos/platform/", "-I/opt/homebrew/include", - "-L/opt/homebrew/lib", - "../common/scaler.c", "../common/utils.c", "../common/api.c", "../common/config.c", "../../macos/platform/platform.c", - "-fomit-frame-pointer", - "-DPLATFORM=\\\"macos\\\"", - "-DUSE_SDL2", "-DUSE_GL", - "-DDEBUG", - "-std=gnu99", "-ldl", "-flto", - "-lSDL2", "-lSDL2_image", "-lSDL2_ttf", "-lpthread", "-lsqlite3", "-framework", "OpenGL", "-lm", "-lz", - //"-fsanitize=address", - "-fno-common", - "-Wno-tautological-constant-out-of-range-compare", - "-Wno-asm-operand-widths", - "-Wno-deprecated-declarations" - ], - "options": { - "cwd": "${workspaceFolder}/workspace/all/minput" - }, - "problemMatcher": [ - "$gcc" - ], - "group": { - "kind": "build", - "isDefault": true - }, - }, - { - "type": "cppbuild", - "label": "C/C++: gcc build macos - Gametime", - "command": "/usr/bin/gcc", - "args": [ - "-g", "gametime.c", "-o", "${workspaceFolder}/workspace/all/gametime/build/macos/gametime", - "-I.", "-I../common/", "-I../../macos/platform/", "-I/opt/homebrew/include", "-I../libgametimedb/", - "-L/opt/homebrew/lib", - "../common/scaler.c", "../common/utils.c", "../common/api.c", "../common/config.c", "../libgametimedb/gametimedb.c", "../../macos/platform/platform.c", - "-fomit-frame-pointer", - "-DPLATFORM=\\\"macos\\\"", - "-DUSE_SDL2", "-DUSE_GL", - "-DDEBUG", - "-std=gnu99", "-ldl", "-flto", - "-lSDL2", "-lSDL2_image", "-lSDL2_ttf", "-lpthread", "-lsqlite3", "-framework", "OpenGL", "-lm", "-lz", - //"-fsanitize=address", - "-fno-common", - "-Wno-tautological-constant-out-of-range-compare", - "-Wno-asm-operand-widths", - "-Wno-deprecated-declarations" - ], - "options": { - "cwd": "${workspaceFolder}/workspace/all/gametime" - }, - "problemMatcher": [ - "$gcc" - ], - "group": { - "kind": "build", - "isDefault": true - }, - }, - { - "type": "cppbuild", - "label": "C/C++: gcc build macos - Gametimectl", - "command": "/usr/bin/gcc", - "args": [ - "-g", "gametimectl.c", "-o", "${workspaceFolder}/workspace/all/gametimectl/build/macos/gametimectl", - "-I.", "-I../common/", "-I../../macos/platform/", "-I/opt/homebrew/include", "-I../libgametimedb/", - "-L/opt/homebrew/lib", - "../common/scaler.c", "../common/utils.c", "../common/api.c", "../libgametimedb/gametimedb.c", "../../macos/platform/platform.c", - "-fomit-frame-pointer", - "-DPLATFORM=\\\"macos\\\"", - "-DUSE_SDL2", "-DUSE_GL", - "-DDEBUG", - "-std=gnu99", "-ldl", "-flto", - "-lSDL2", "-lSDL2_image", "-lSDL2_ttf", "-lpthread", "-lsqlite3", "-lm", "-lz", - //"-fsanitize=address", - "-fno-common", - "-Wno-tautological-constant-out-of-range-compare", - "-Wno-asm-operand-widths", - "-Wno-deprecated-declarations" - ], - "options": { - "cwd": "${workspaceFolder}/workspace/all/gametimectl" - }, - "problemMatcher": [ - "$gcc" - ], - "group": { - "kind": "build", - "isDefault": true - }, - }, - { - "type": "cppbuild", - "label": "C/C++: gcc build macos - Settings", - "command": "/opt/homebrew/Cellar/gcc/14.2.0_1/bin/g++-14", - "args": [ - "-g", "settings.cpp", "menu.cpp", "wifimenu.cpp","keyboardprompt.cpp", "-o", "${workspaceFolder}/workspace/all/settings/build/macos/settings", - "-I.", "-I../common/", "-I../../macos/platform/", "-I/opt/homebrew/include", - "-L/opt/homebrew/lib", - "../common/build/macos/utils.o", "../common/build/macos/api.o", "../common/build/macos/config.o", "../common/build/macos/platform.o", "../common/build/macos/scaler.o", - "-fomit-frame-pointer", - "-DPLATFORM=\\\"macos\\\"", - "-DUSE_SDL2", "-DUSE_GL", - "-DDEBUG", "-ldl", "-flto", - "-std=c++17", - "-lSDL2", "-lSDL2_image", "-lSDL2_ttf", "-lpthread", "-framework", "OpenGL", "-lm", "-lz", "-lsamplerate", - //"-fpermissive", - //"-fsanitize=address", - ], - "options": { - "cwd": "${workspaceFolder}/workspace/all/settings" - }, - "problemMatcher": [ - "$gcc" - ], - "group": { - "kind": "build", - "isDefault": true - }, - "dependsOn":["C/C++: gcc build macos - Utils"] - }, - { - "type": "cppbuild", - "label": "C/C++: gcc build macos - Utils make", - "command": "/opt/homebrew/Cellar/gcc/14.2.0_1/bin/gcc-14", - "args": [ - "-g", - "-I.", "-I../common/", "-I../../macos/platform/", "-I/opt/homebrew/include", - "-L/opt/homebrew/lib", - "-c", "../common/utils.c", "../common/api.c", "../common/config.c", "../common/scaler.c", "../../macos/platform/platform.c", - "-fomit-frame-pointer", - "-DPLATFORM=\\\"macos\\\"", - "-DUSE_SDL2", "-DUSE_GL", - "-DDEBUG", "-ldl", "-flto", - "-lSDL2", "-lSDL2_image", "-lSDL2_ttf", "-lpthread", "-framework", "OpenGL", "-lm", "-lz", "-lsamplerate", - "-fpermissive", - // just C stuff, string.h, etc - "-Wno-write-strings", - // void pointer math in api.c - "-Wno-pointer-arith", - //"-v" - ], - "options": { - "cwd": "${workspaceFolder}/workspace/all/common" - }, - "problemMatcher": [ - "$gcc" - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { + "label": "make desktop", "type": "shell", - "label": "C/C++: gcc build macos - Utils", - "command": "mkdir -p ${workspaceFolder}/workspace/all/common/build/macos && mv *.o ${workspaceFolder}/workspace/all/common/build/macos/", - "args": [], - "options": { - "cwd": "${workspaceFolder}/workspace/all/common" - }, + "command": "make clean PLATFORM=desktop && make setup common PLATFORM=desktop", "group": { "kind": "build", "isDefault": true }, - "dependsOn":["C/C++: gcc build macos - Utils make"] + "problemMatcher": "$gcc" } - - ], - "version": "2.0.0" + ] } \ No newline at end of file diff --git a/makefile b/makefile index 9f731eaa3..cffb98b69 100644 --- a/makefile +++ b/makefile @@ -25,6 +25,11 @@ ifeq ($(BUILD_BRANCH),main) else RELEASE_BETA := -$(BUILD_BRANCH) endif +ifeq ($(PLATFORM), desktop) + TOOLCHAIN_FILE := makefile.native +else + TOOLCHAIN_FILE := makefile.toolchain +endif RELEASE_BASE=NextUI-$(RELEASE_TIME)$(RELEASE_BETA) RELEASE_DOT:=$(shell find ./releases/. -regex ".*/${RELEASE_BASE}-[0-9]+-base\.zip" | wc -l | sed 's/ //g') RELEASE_NAME ?= $(RELEASE_BASE)-$(RELEASE_DOT) @@ -38,38 +43,40 @@ export MAKEFLAGS=--no-print-directory all: setup $(PLATFORMS) special package done shell: - make -f makefile.toolchain PLATFORM=$(PLATFORM) + make -f $(TOOLCHAIN_FILE) PLATFORM=$(PLATFORM) name: @echo $(RELEASE_NAME) build: # ---------------------------------------------------- - make build -f makefile.toolchain PLATFORM=$(PLATFORM) COMPILE_CORES=$(COMPILE_CORES) + make build -f $(TOOLCHAIN_FILE) PLATFORM=$(PLATFORM) COMPILE_CORES=$(COMPILE_CORES) # ---------------------------------------------------- build-cores: - make build-cores -f makefile.toolchain PLATFORM=$(PLATFORM) COMPILE_CORES=true + make build-cores -f $(TOOLCHAIN_FILE) PLATFORM=$(PLATFORM) COMPILE_CORES=true # ---------------------------------------------------- cores-json: - @cat workspace/tg5040/cores/makefile | grep ^CORES | cut -d' ' -f2 | jq --raw-input . | jq --slurp -cM . + @cat workspace/$(PLATFORM)/cores/makefile | grep ^CORES | cut -d' ' -f2 | jq --raw-input . | jq --slurp -cM . build-core: ifndef CORE $(error CORE is not set) endif - make build-core -f makefile.toolchain PLATFORM=$(PLATFORM) COMPILE_CORES=true CORE=$(CORE) + make build-core -f $(TOOLCHAIN_FILE) PLATFORM=$(PLATFORM) COMPILE_CORES=true CORE=$(CORE) system: make -f ./workspace/$(PLATFORM)/platform/makefile.copy PLATFORM=$(PLATFORM) # populate system +ifneq ($(PLATFORM), desktop) cp ./workspace/$(PLATFORM)/keymon/keymon.elf ./build/SYSTEM/$(PLATFORM)/bin/ + cp ./workspace/all/syncsettings/build/$(PLATFORM)/syncsettings.elf ./build/SYSTEM/$(PLATFORM)/bin/ +endif cp ./workspace/$(PLATFORM)/libmsettings/libmsettings.so ./build/SYSTEM/$(PLATFORM)/lib cp ./workspace/all/nextui/build/$(PLATFORM)/nextui.elf ./build/SYSTEM/$(PLATFORM)/bin/ cp ./workspace/all/minarch/build/$(PLATFORM)/minarch.elf ./build/SYSTEM/$(PLATFORM)/bin/ - cp ./workspace/all/syncsettings/build/$(PLATFORM)/syncsettings.elf ./build/SYSTEM/$(PLATFORM)/bin/ cp ./workspace/all/nextval/build/$(PLATFORM)/nextval.elf ./build/SYSTEM/$(PLATFORM)/bin/ cp ./workspace/all/clock/build/$(PLATFORM)/clock.elf ./build/EXTRAS/Tools/$(PLATFORM)/Clock.pak/ cp ./workspace/all/minput/build/$(PLATFORM)/minput.elf ./build/EXTRAS/Tools/$(PLATFORM)/Input.pak/ @@ -99,6 +106,11 @@ ifeq ($(PLATFORM), tg5040) endif +ifeq ($(PLATFORM), desktop) +cores: + # stock cores + # cp ./workspace/$(PLATFORM)/cores/output/gambatte_libretro.so ./build/SYSTEM/$(PLATFORM)/cores +else cores: # TODO: can't assume every platform will have the same stock cores (platform should be responsible for copy too) # stock cores cp ./workspace/$(PLATFORM)/cores/output/fceumm_libretro.so ./build/SYSTEM/$(PLATFORM)/cores @@ -135,11 +147,13 @@ endif cp ./workspace/$(PLATFORM)/cores/output/vice_xplus4_libretro.so ./build/EXTRAS/Emus/$(PLATFORM)/PLUS4.pak cp ./workspace/$(PLATFORM)/cores/output/vice_xpet_libretro.so ./build/EXTRAS/Emus/$(PLATFORM)/PET.pak cp ./workspace/$(PLATFORM)/cores/output/vice_xvic_libretro.so ./build/EXTRAS/Emus/$(PLATFORM)/VIC.pak +endif common: build system cores clean: rm -rf ./build + make clean -f $(TOOLCHAIN_FILE) PLATFORM=$(PLATFORM) COMPILE_CORES=$(COMPILE_CORES) setup: name # ---------------------------------------------------- diff --git a/makefile.native b/makefile.native new file mode 100644 index 000000000..2093b306c --- /dev/null +++ b/makefile.native @@ -0,0 +1,43 @@ +# there is no reason to use this makefile manually + +.PHONY: build clean + +ifeq (,$(PLATFORM)) +$(error please specify PLATFORM, eg. make PLATFORM=tg5040) +endif + +.EXPORT_ALL_VARIABLES: +# pseudo toolchain +UNAME_S := $(shell uname -s) +ifeq ($(UNAME_S),Linux) + CROSS_COMPILE=/usr/bin/ + PREFIX=/usr + PREFIX_LOCAL=/opt/nextui +endif +ifeq ($(UNAME_S),Darwin) + # TODO: brew installs gcc to e.g. /opt/homebrew/bin/gcc-14, but none of our makefiles support the suffix. + # For now, just manually symlink all the build tools to a suffix-less path: sudo ./workspace/desktop/macos_create_gcc_symlinks.sh + # and make with: make setup common PLATFORM=desktop + # From brew we need at least: brew install sdl2_image sdl2_ttf gcc make libsamplerate sqlite + CROSS_COMPILE=/usr/local/bin/ + PREFIX=/opt/homebrew + PREFIX_LOCAL=/opt/homebrew +endif +UNION_PLATFORM=desktop + +all: + +clean: + cd workspace && make clean + +build: + COMPILE_CORES=$(COMPILE_CORES) cd workspace && make + +build-cores: + COMPILE_CORES=$(COMPILE_CORES) cd workspace && make cores + +build-core: +ifndef CORE + $(error CORE is not set) +endif + COMPILE_CORES=$(COMPILE_CORES) CORE=$(CORE) cd workspace && make core diff --git a/makefile.toolchain b/makefile.toolchain index 0b2eadaf2..c1d508b50 100644 --- a/makefile.toolchain +++ b/makefile.toolchain @@ -1,6 +1,6 @@ # there is no reason to use this makefile manually -.PHONY: build +.PHONY: build clean ifeq (,$(PLATFORM)) $(error please specify PLATFORM, eg. make PLATFORM=trimui) diff --git a/skeleton/EXTRAS/Tools/desktop/Battery.pak/launch.sh b/skeleton/EXTRAS/Tools/desktop/Battery.pak/launch.sh new file mode 100755 index 000000000..c7cd4fcde --- /dev/null +++ b/skeleton/EXTRAS/Tools/desktop/Battery.pak/launch.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +cd $(dirname "$0") +./battery.elf # &> ./log.txt diff --git a/skeleton/EXTRAS/Tools/desktop/Clock.pak/launch.sh b/skeleton/EXTRAS/Tools/desktop/Clock.pak/launch.sh new file mode 100755 index 000000000..34c09b523 --- /dev/null +++ b/skeleton/EXTRAS/Tools/desktop/Clock.pak/launch.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +cd $(dirname "$0") +./clock.elf # &> ./log.txt diff --git a/skeleton/EXTRAS/Tools/desktop/Game Tracker.pak/launch.sh b/skeleton/EXTRAS/Tools/desktop/Game Tracker.pak/launch.sh new file mode 100755 index 000000000..86e09ee15 --- /dev/null +++ b/skeleton/EXTRAS/Tools/desktop/Game Tracker.pak/launch.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +cd "$(dirname "$0")" +./gametime.elf # &> ./log.txt diff --git a/skeleton/EXTRAS/Tools/desktop/Input.pak/launch.sh b/skeleton/EXTRAS/Tools/desktop/Input.pak/launch.sh new file mode 100755 index 000000000..ca0aefe28 --- /dev/null +++ b/skeleton/EXTRAS/Tools/desktop/Input.pak/launch.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +cd $(dirname "$0") +./minput.elf diff --git a/skeleton/EXTRAS/Tools/desktop/Settings.pak/launch.sh b/skeleton/EXTRAS/Tools/desktop/Settings.pak/launch.sh new file mode 100644 index 000000000..006467eae --- /dev/null +++ b/skeleton/EXTRAS/Tools/desktop/Settings.pak/launch.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +SDCARD_PATH="/mnt/SDCARD" +USERDATA_PATH="$SDCARD_PATH/.userdata" +SHARED_USERDATA_PATH="$USERDATA_PATH/shared" + +cd $(dirname "$0") +./settings.elf > settings.log 2>&1 diff --git a/skeleton/SYSTEM/tg5040/bin/.keep b/skeleton/SYSTEM/desktop/bin/.keep similarity index 100% rename from skeleton/SYSTEM/tg5040/bin/.keep rename to skeleton/SYSTEM/desktop/bin/.keep diff --git a/skeleton/SYSTEM/desktop/cores/.keep b/skeleton/SYSTEM/desktop/cores/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/skeleton/SYSTEM/desktop/lib/.keep b/skeleton/SYSTEM/desktop/lib/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/skeleton/SYSTEM/desktop/paks/Emus/FC.pak/default.cfg b/skeleton/SYSTEM/desktop/paks/Emus/FC.pak/default.cfg new file mode 100755 index 000000000..90365a9d1 --- /dev/null +++ b/skeleton/SYSTEM/desktop/paks/Emus/FC.pak/default.cfg @@ -0,0 +1,20 @@ +fceumm_sndquality = High +fceumm_sndvolume = 10 +-fceumm_aspect = 8:7 PAR +-fceumm_turbo_enable = Player 1 +-fceumm_show_adv_system_options = disabled +-fceumm_show_adv_sound_options = disabled + +bind Up = UP +bind Down = DOWN +bind Left = LEFT +bind Right = RIGHT +bind Select = SELECT +bind Start = START +bind A Button = A +bind B Button = B +bind A Turbo = NONE:X +bind B Turbo = NONE:Y +bind Change Disk = NONE:L1 +bind Insert Disk = NONE:R1 +bind Insert Coin = NONE:R2 diff --git a/skeleton/SYSTEM/desktop/paks/Emus/FC.pak/launch.sh b/skeleton/SYSTEM/desktop/paks/Emus/FC.pak/launch.sh new file mode 100755 index 000000000..280598bbc --- /dev/null +++ b/skeleton/SYSTEM/desktop/paks/Emus/FC.pak/launch.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +EMU_EXE=fceumm + +############################### + +EMU_TAG=$(basename "$(dirname "$0")" .pak) +ROM="$1" +mkdir -p "$BIOS_PATH/$EMU_TAG" +mkdir -p "$SAVES_PATH/$EMU_TAG" +mkdir -p "$CHEATS_PATH/$EMU_TAG" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" &> "$LOGS_PATH/$EMU_TAG.txt" diff --git a/skeleton/SYSTEM/desktop/paks/Emus/GB.pak/default.cfg b/skeleton/SYSTEM/desktop/paks/Emus/GB.pak/default.cfg new file mode 100644 index 000000000..423879243 --- /dev/null +++ b/skeleton/SYSTEM/desktop/paks/Emus/GB.pak/default.cfg @@ -0,0 +1,20 @@ +# use core fps, screen might be 240Hz or whatever +minarch_sync_reference = Native +gambatte_gb_colorization = internal +gambatte_gb_internal_palette = TWB64 - Pack 1 +gambatte_gb_palette_twb64_1 = TWB64 038 - Pokemon mini Ver. +gambatte_gb_bootloader = disabled +-gambatte_audio_resampler = sinc + +bind Up = UP +bind Down = DOWN +bind Left = LEFT +bind Right = RIGHT +bind Select = SELECT +bind Start = START +bind A Button = A +bind B Button = B +bind A Turbo = NONE:X +bind B Turbo = NONE:Y +bind Prev. Palette = NONE:L1 +bind Next Palette = NONE:R1 diff --git a/skeleton/SYSTEM/desktop/paks/Emus/GB.pak/launch.sh b/skeleton/SYSTEM/desktop/paks/Emus/GB.pak/launch.sh new file mode 100755 index 000000000..9143f24c9 --- /dev/null +++ b/skeleton/SYSTEM/desktop/paks/Emus/GB.pak/launch.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +EMU_EXE=gambatte + +############################### + +EMU_TAG=$(basename "$(dirname "$0")" .pak) +ROM="$1" +mkdir -p "$BIOS_PATH/$EMU_TAG" +mkdir -p "$SAVES_PATH/$EMU_TAG" +mkdir -p "$CHEATS_PATH/$EMU_TAG" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" &> "$LOGS_PATH/$EMU_TAG.txt" diff --git a/skeleton/SYSTEM/desktop/paks/Emus/GBA.pak/default.cfg b/skeleton/SYSTEM/desktop/paks/Emus/GBA.pak/default.cfg new file mode 100755 index 000000000..ea76e21f6 --- /dev/null +++ b/skeleton/SYSTEM/desktop/paks/Emus/GBA.pak/default.cfg @@ -0,0 +1,14 @@ +-gpsp_save_method = libretro + +bind Up = UP +bind Down = DOWN +bind Left = LEFT +bind Right = RIGHT +bind Select = SELECT +bind Start = START +bind A Button = A +bind B Button = B +bind A Turbo = NONE:X +bind B Turbo = NONE:Y +bind L Button = L1 +bind R Button = R1 diff --git a/skeleton/SYSTEM/desktop/paks/Emus/GBA.pak/launch.sh b/skeleton/SYSTEM/desktop/paks/Emus/GBA.pak/launch.sh new file mode 100755 index 000000000..5678aaca7 --- /dev/null +++ b/skeleton/SYSTEM/desktop/paks/Emus/GBA.pak/launch.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +EMU_EXE=gpsp + +############################### + +EMU_TAG=$(basename "$(dirname "$0")" .pak) +ROM="$1" +mkdir -p "$BIOS_PATH/$EMU_TAG" +mkdir -p "$SAVES_PATH/$EMU_TAG" +mkdir -p "$CHEATS_PATH/$EMU_TAG" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" &> "$LOGS_PATH/$EMU_TAG.txt" diff --git a/skeleton/SYSTEM/desktop/paks/Emus/GBC.pak/default.cfg b/skeleton/SYSTEM/desktop/paks/Emus/GBC.pak/default.cfg new file mode 100755 index 000000000..606e7b74c --- /dev/null +++ b/skeleton/SYSTEM/desktop/paks/Emus/GBC.pak/default.cfg @@ -0,0 +1,15 @@ +gambatte_gb_bootloader = disabled +-gambatte_audio_resampler = sinc + +bind Up = UP +bind Down = DOWN +bind Left = LEFT +bind Right = RIGHT +bind Select = SELECT +bind Start = START +bind A Button = A +bind B Button = B +bind A Turbo = NONE:X +bind B Turbo = NONE:Y +bind Prev. Palette = NONE:L1 +bind Next Palette = NONE:R1 diff --git a/skeleton/SYSTEM/desktop/paks/Emus/GBC.pak/launch.sh b/skeleton/SYSTEM/desktop/paks/Emus/GBC.pak/launch.sh new file mode 100755 index 000000000..9143f24c9 --- /dev/null +++ b/skeleton/SYSTEM/desktop/paks/Emus/GBC.pak/launch.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +EMU_EXE=gambatte + +############################### + +EMU_TAG=$(basename "$(dirname "$0")" .pak) +ROM="$1" +mkdir -p "$BIOS_PATH/$EMU_TAG" +mkdir -p "$SAVES_PATH/$EMU_TAG" +mkdir -p "$CHEATS_PATH/$EMU_TAG" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" &> "$LOGS_PATH/$EMU_TAG.txt" diff --git a/skeleton/SYSTEM/desktop/paks/Emus/MD.pak/default.cfg b/skeleton/SYSTEM/desktop/paks/Emus/MD.pak/default.cfg new file mode 100755 index 000000000..dac408932 --- /dev/null +++ b/skeleton/SYSTEM/desktop/paks/Emus/MD.pak/default.cfg @@ -0,0 +1,18 @@ +-picodrive_sound_rate = 44100 +-picodrive_smstype = Auto +-picodrive_smsfm = off +-picodrive_smsmapper = Auto +-picodrive_ggghost = off + +bind Up = UP +bind Down = DOWN +bind Left = LEFT +bind Right = RIGHT +bind Mode = SELECT +bind Start = START +bind A Button = Y +bind B Button = X:B +bind C Button = A +bind X Button = B:L1 +bind Y Button = L1:X +bind Z Button = R1 diff --git a/skeleton/SYSTEM/desktop/paks/Emus/MD.pak/launch.sh b/skeleton/SYSTEM/desktop/paks/Emus/MD.pak/launch.sh new file mode 100755 index 000000000..81688be79 --- /dev/null +++ b/skeleton/SYSTEM/desktop/paks/Emus/MD.pak/launch.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +EMU_EXE=picodrive + +############################### + +EMU_TAG=$(basename "$(dirname "$0")" .pak) +ROM="$1" +mkdir -p "$BIOS_PATH/$EMU_TAG" +mkdir -p "$SAVES_PATH/$EMU_TAG" +mkdir -p "$CHEATS_PATH/$EMU_TAG" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" &> "$LOGS_PATH/$EMU_TAG.txt" diff --git a/skeleton/SYSTEM/desktop/paks/Emus/PS.pak/default.cfg b/skeleton/SYSTEM/desktop/paks/Emus/PS.pak/default.cfg new file mode 100755 index 000000000..67f23b5b7 --- /dev/null +++ b/skeleton/SYSTEM/desktop/paks/Emus/PS.pak/default.cfg @@ -0,0 +1,21 @@ +-minarch_prevent_tearing = Strict +-pcsx_rearmed_display_internal_fps = disabled +-pcsx_rearmed_show_input_settings = disabled + +pcsx_rearmed_dithering = enabled + +minarch_gamepad_type = 1 +bind Up = UP +bind Down = DOWN +bind Left = LEFT +bind Right = RIGHT +bind Select = SELECT +bind Start = START +bind Circle = A +bind Cross = B +bind Triangle = X +bind Square = Y +bind L1 Button = L1 +bind R1 Button = R1 +bind L2 Button = L2 +bind R2 Button = R2 \ No newline at end of file diff --git a/skeleton/SYSTEM/desktop/paks/Emus/PS.pak/launch.sh b/skeleton/SYSTEM/desktop/paks/Emus/PS.pak/launch.sh new file mode 100755 index 000000000..e3ba5ac06 --- /dev/null +++ b/skeleton/SYSTEM/desktop/paks/Emus/PS.pak/launch.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +EMU_EXE=pcsx_rearmed + +############################### + +EMU_TAG=$(basename "$(dirname "$0")" .pak) +ROM="$1" +mkdir -p "$BIOS_PATH/$EMU_TAG" +mkdir -p "$SAVES_PATH/$EMU_TAG" +mkdir -p "$CHEATS_PATH/$EMU_TAG" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" &> "$LOGS_PATH/$EMU_TAG.txt" diff --git a/skeleton/SYSTEM/desktop/paks/Emus/SFC.pak/default.cfg b/skeleton/SYSTEM/desktop/paks/Emus/SFC.pak/default.cfg new file mode 100755 index 000000000..8100f20a1 --- /dev/null +++ b/skeleton/SYSTEM/desktop/paks/Emus/SFC.pak/default.cfg @@ -0,0 +1,12 @@ +bind Up = UP +bind Down = DOWN +bind Left = LEFT +bind Right = RIGHT +bind Select = SELECT +bind Start = START +bind Y Button = Y +bind X Button = X +bind B Button = B +bind A Button = A +bind L Button = L1 +bind R Button = R1 \ No newline at end of file diff --git a/skeleton/SYSTEM/desktop/paks/Emus/SFC.pak/launch.sh b/skeleton/SYSTEM/desktop/paks/Emus/SFC.pak/launch.sh new file mode 100755 index 000000000..155233127 --- /dev/null +++ b/skeleton/SYSTEM/desktop/paks/Emus/SFC.pak/launch.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +EMU_EXE=snes9x + +############################### + +EMU_TAG=$(basename "$(dirname "$0")" .pak) +ROM="$1" +mkdir -p "$BIOS_PATH/$EMU_TAG" +mkdir -p "$SAVES_PATH/$EMU_TAG" +mkdir -p "$CHEATS_PATH/$EMU_TAG" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" &> "$LOGS_PATH/$EMU_TAG.txt" diff --git a/skeleton/SYSTEM/desktop/paks/MinUI.pak/launch.sh b/skeleton/SYSTEM/desktop/paks/MinUI.pak/launch.sh new file mode 100755 index 000000000..0ac22e1cb --- /dev/null +++ b/skeleton/SYSTEM/desktop/paks/MinUI.pak/launch.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# MinUI.pak + +export PLATFORM="desktop" +export SDCARD_PATH="/Library/Developer/Projects/private/MinUI_FAKESD" +export BIOS_PATH="$SDCARD_PATH/Bios" +export ROMS_PATH="$SDCARD_PATH/Roms" +export SAVES_PATH="$SDCARD_PATH/Saves" +export CHEATS_PATH="$SDCARD_PATH/Cheats" +export SYSTEM_PATH="$SDCARD_PATH/.system/$PLATFORM" +export CORES_PATH="$SYSTEM_PATH/cores" +export USERDATA_PATH="$SDCARD_PATH/.userdata/$PLATFORM" +export SHARED_USERDATA_PATH="$SDCARD_PATH/.userdata/shared" +export LOGS_PATH="$USERDATA_PATH/logs" +export DATETIME_PATH="$SHARED_USERDATA_PATH/datetime.txt" + +mkdir -p "$BIOS_PATH" +mkdir -p "$ROMS_PATH" +mkdir -p "$SAVES_PATH" +mkdir -p "$CHEATS_PATH" +mkdir -p "$USERDATA_PATH" +mkdir -p "$LOGS_PATH" +mkdir -p "$SHARED_USERDATA_PATH/.minui" + +export IS_NEXT="yes" + +####################################### + +export LD_LIBRARY_PATH=$SYSTEM_PATH/lib:$LD_LIBRARY_PATH +export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH:$DYLD_LIBRARY_PATH +export PATH=$SYSTEM_PATH/bin:$PATH + +#batmon.elf & # &> $SDCARD_PATH/batmon.txt & + +####################################### + +AUTO_PATH=$USERDATA_PATH/auto.sh +if [ -f "$AUTO_PATH" ]; then + "$AUTO_PATH" +fi + +cd $(dirname "$0") + +####################################### + +EXEC_PATH="/tmp/nextui_exec" +NEXT_PATH="/tmp/next" +touch "$EXEC_PATH" && sync +#while [ -f $EXEC_PATH ]; do + nextui.elf # &> $LOGS_PATH/nextui.txt + + if [ -f $NEXT_PATH ]; then + CMD=`cat $NEXT_PATH` + eval $CMD + rm -f $NEXT_PATH + fi +#done diff --git a/skeleton/SYSTEM/desktop/shaders/colorfix.glsl b/skeleton/SYSTEM/desktop/shaders/colorfix.glsl new file mode 100644 index 000000000..cad64ec0f --- /dev/null +++ b/skeleton/SYSTEM/desktop/shaders/colorfix.glsl @@ -0,0 +1,20 @@ +#if defined(VERTEX) +attribute vec2 VertexCoord; +attribute vec2 TexCoord; +varying vec2 vTexCoord; + +void main() { + vTexCoord = TexCoord; + gl_Position = vec4(VertexCoord, 0.0, 1.0); +} +#endif + +#if defined(FRAGMENT) +uniform sampler2D Texture; +varying vec2 vTexCoord; + +void main() { + vec4 pixel = texture2D(Texture, vec2(vTexCoord.x, 1.0 - vTexCoord.y)); + gl_FragColor = vec4(pixel.a, pixel.b, pixel.g, pixel.r); +} +#endif \ No newline at end of file diff --git a/skeleton/SYSTEM/desktop/shaders/default.glsl b/skeleton/SYSTEM/desktop/shaders/default.glsl new file mode 100644 index 000000000..240b76184 --- /dev/null +++ b/skeleton/SYSTEM/desktop/shaders/default.glsl @@ -0,0 +1,20 @@ +#if defined(VERTEX) +attribute vec2 VertexCoord; +attribute vec2 TexCoord; +varying vec2 vTexCoord; + +void main() { + // Flip Y-axis in the vertex shader + vTexCoord = vec2(TexCoord.x, 1.0 - TexCoord.y); // Flip Y + gl_Position = vec4(VertexCoord, 0.0, 1.0); +} +#endif + +#if defined(FRAGMENT) +uniform sampler2D Texture; +varying vec2 vTexCoord; + +void main() { + gl_FragColor = texture2D(Texture, vTexCoord); +} +#endif \ No newline at end of file diff --git a/skeleton/SYSTEM/desktop/shaders/noshader.glsl b/skeleton/SYSTEM/desktop/shaders/noshader.glsl new file mode 100644 index 000000000..bb16948db --- /dev/null +++ b/skeleton/SYSTEM/desktop/shaders/noshader.glsl @@ -0,0 +1,20 @@ +#if defined(VERTEX) +attribute vec2 VertexCoord; +attribute vec2 TexCoord; +varying vec2 vTexCoord; + +void main() { + // Flip Y-axis in the vertex shader + vTexCoord = vec2(TexCoord.x, TexCoord.y); // Flip Y + gl_Position = vec4(VertexCoord, 0.0, 1.0); +} +#endif + +#if defined(FRAGMENT) +uniform sampler2D Texture; +varying vec2 vTexCoord; + +void main() { + gl_FragColor = texture2D(Texture, vTexCoord); +} +#endif \ No newline at end of file diff --git a/skeleton/SYSTEM/desktop/shaders/overlay.glsl b/skeleton/SYSTEM/desktop/shaders/overlay.glsl new file mode 100644 index 000000000..bce6a2642 --- /dev/null +++ b/skeleton/SYSTEM/desktop/shaders/overlay.glsl @@ -0,0 +1,19 @@ +#if defined(VERTEX) +attribute vec2 VertexCoord; +attribute vec2 TexCoord; +varying vec2 vTexCoord; + +void main() { + vTexCoord = TexCoord; + gl_Position = vec4(VertexCoord, 0.0, 1.0); +} +#endif + +#if defined(FRAGMENT) +uniform sampler2D Texture; +varying vec2 vTexCoord; + +void main() { + gl_FragColor = texture2D(Texture, vec2(vTexCoord.x, 1.0 - vTexCoord.y)); +} +#endif \ No newline at end of file diff --git a/skeleton/SYSTEM/desktop/shaders/pixellate.glsl b/skeleton/SYSTEM/desktop/shaders/pixellate.glsl new file mode 100644 index 000000000..aa248462f --- /dev/null +++ b/skeleton/SYSTEM/desktop/shaders/pixellate.glsl @@ -0,0 +1,143 @@ +// Pixellate Shader +// Copyright (c) 2011, 2012 Fes +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +// IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// (Fes gave their permission to have this shader distributed under this +// licence in this forum post: +// http://board.byuu.org/viewtopic.php?p=57295#p57295 + +// Parameter lines go here: +#pragma parameter INTERPOLATE_IN_LINEAR_GAMMA "Linear Gamma Weight" 1.0 0.0 1.0 1.0 + +#if defined(VERTEX) + +#if __VERSION__ >= 130 +#define COMPAT_VARYING out +#define COMPAT_ATTRIBUTE in +#define COMPAT_TEXTURE texture +#else +#define COMPAT_VARYING varying +#define COMPAT_ATTRIBUTE attribute +#define COMPAT_TEXTURE texture2D +#endif + +#ifdef GL_ES +#define COMPAT_PRECISION mediump +#else +#define COMPAT_PRECISION +#endif + +COMPAT_ATTRIBUTE vec4 VertexCoord; +COMPAT_ATTRIBUTE vec4 COLOR; +COMPAT_ATTRIBUTE vec4 TexCoord; +COMPAT_VARYING vec4 COL0; +COMPAT_VARYING vec4 TEX0; + +uniform mat4 MVPMatrix; +uniform COMPAT_PRECISION int FrameDirection; +uniform COMPAT_PRECISION int FrameCount; +uniform COMPAT_PRECISION vec2 OutputSize; +uniform COMPAT_PRECISION vec2 TextureSize; +uniform COMPAT_PRECISION vec2 InputSize; + +// vertex compatibility #defines +#define vTexCoord TEX0.xy +#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize +#define outsize vec4(OutputSize, 1.0 / OutputSize) + +void main() +{ + gl_Position = MVPMatrix * VertexCoord; + COL0 = COLOR; + TEX0.xy = TexCoord.xy; +} + +#elif defined(FRAGMENT) + +#if __VERSION__ >= 130 +#define COMPAT_VARYING in +#define COMPAT_TEXTURE texture +out vec4 FragColor; +#else +#define COMPAT_VARYING varying +#define FragColor gl_FragColor +#define COMPAT_TEXTURE texture2D +#endif + +#ifdef GL_ES +#ifdef GL_FRAGMENT_PRECISION_HIGH +precision highp float; +#else +precision mediump float; +#endif +#define COMPAT_PRECISION highp +#else +#define COMPAT_PRECISION +#endif + +uniform COMPAT_PRECISION int FrameDirection; +uniform COMPAT_PRECISION int FrameCount; +uniform COMPAT_PRECISION vec2 OutputSize; +uniform COMPAT_PRECISION vec2 TextureSize; +uniform COMPAT_PRECISION vec2 InputSize; +uniform sampler2D Texture; +COMPAT_VARYING vec4 TEX0; + +// fragment compatibility #defines +#define Source Texture +#define vTexCoord TEX0.xy + +#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize +#define outsize vec4(OutputSize, 1.0 / OutputSize) + +#ifdef PARAMETER_UNIFORM +uniform COMPAT_PRECISION float INTERPOLATE_IN_LINEAR_GAMMA; +#else +#define INTERPOLATE_IN_LINEAR_GAMMA 1.0 +#endif + +void main() +{ + vec2 texelSize = SourceSize.zw; + + vec2 range = vec2(abs(InputSize.x / (outsize.x * SourceSize.x)), abs(InputSize.y / (outsize.y * SourceSize.y))); + range = range / 2.0 * 0.999; + + float left = vTexCoord.x - range.x; + float top = vTexCoord.y + range.y; + float right = vTexCoord.x + range.x; + float bottom = vTexCoord.y - range.y; + + vec3 topLeftColor = COMPAT_TEXTURE(Source, (floor(vec2(left, top) / texelSize) + 0.5) * texelSize).rgb; + vec3 bottomRightColor = COMPAT_TEXTURE(Source, (floor(vec2(right, bottom) / texelSize) + 0.5) * texelSize).rgb; + vec3 bottomLeftColor = COMPAT_TEXTURE(Source, (floor(vec2(left, bottom) / texelSize) + 0.5) * texelSize).rgb; + vec3 topRightColor = COMPAT_TEXTURE(Source, (floor(vec2(right, top) / texelSize) + 0.5) * texelSize).rgb; + + if (INTERPOLATE_IN_LINEAR_GAMMA > 0.5){ + topLeftColor = pow(topLeftColor, vec3(2.2)); + bottomRightColor = pow(bottomRightColor, vec3(2.2)); + bottomLeftColor = pow(bottomLeftColor, vec3(2.2)); + topRightColor = pow(topRightColor, vec3(2.2)); + } + + vec2 border = clamp(floor((vTexCoord / texelSize) + vec2(0.5)) * texelSize, vec2(left, bottom), vec2(right, top)); + + float totalArea = 4.0 * range.x * range.y; + + vec3 averageColor; + averageColor = ((border.x - left) * (top - border.y) / totalArea) * topLeftColor; + averageColor += ((right - border.x) * (border.y - bottom) / totalArea) * bottomRightColor; + averageColor += ((border.x - left) * (border.y - bottom) / totalArea) * bottomLeftColor; + averageColor += ((right - border.x) * (top - border.y) / totalArea) * topRightColor; + + FragColor = (INTERPOLATE_IN_LINEAR_GAMMA > 0.5) ? vec4(pow(averageColor, vec3(1.0 / 2.2)), 1.0) : vec4(averageColor, 1.0); +} +#endif diff --git a/skeleton/SYSTEM/desktop/system.cfg b/skeleton/SYSTEM/desktop/system.cfg new file mode 100755 index 000000000..c6efdee6d --- /dev/null +++ b/skeleton/SYSTEM/desktop/system.cfg @@ -0,0 +1,20 @@ +minarch_screen_scaling = Fullscreen +minarch_nrofshaders = 0 +minarch_shader1 = stock.glsl +minarch_shader1_filter = NEAREST +minarch_shader1_srctype = source +minarch_shader1_scaletype = source +minarch_shader1_upscale = 2 +minarch_shader2 = stock.glsl +minarch_shader2_filter = LINEAR +minarch_shader2_srctype = relative +minarch_shader2_scaletype = relative +minarch_shader2_upscale = 1 +minarch_shader3 = stock.glsl +minarch_shader3_filter = NEAREST +minarch_shader3_srctype = source +minarch_shader3_scaletype = source +minarch_shader3_upscale = screen +minarch_scale_filter = NEAREST +-minarch_prevent_tearing = Strict +-minarch_thread_video = Off diff --git a/workspace/all/batmon/makefile b/workspace/all/batmon/makefile index e9e66c789..f0ede7125 100644 --- a/workspace/all/batmon/makefile +++ b/workspace/all/batmon/makefile @@ -21,7 +21,7 @@ SDL?=SDL TARGET = batmon INCDIR = -I. -I../common/ -I../../$(PLATFORM)/platform/ -SOURCE = $(TARGET).c ../common/utils.c ../common/api.c ../../$(PLATFORM)/platform/platform.c +SOURCE = $(TARGET).c ../common/utils.c ../common/api.c ../common/config.c ../common/scaler.c ../../$(PLATFORM)/platform/platform.c CC = $(CROSS_COMPILE)gcc CFLAGS += $(ARCH) -fomit-frame-pointer @@ -30,8 +30,8 @@ LDFLAGS += -lmsettings -lbatmondb -lsqlite3 PRODUCT= build/$(PLATFORM)/$(TARGET).elf -all: $(PREFIX)/include/msettings.h +all: $(PREFIX_LOCAL)/include/msettings.h mkdir -p build/$(PLATFORM) $(CC) $(SOURCE) -o $(PRODUCT) $(CFLAGS) $(LDFLAGS) clean: - rm -f $(PRODUCT) \ No newline at end of file + rm -f $(PRODUCT) diff --git a/workspace/all/battery/macos.txt b/workspace/all/battery/macos.txt deleted file mode 100644 index a595755d0..000000000 --- a/workspace/all/battery/macos.txt +++ /dev/null @@ -1,9 +0,0 @@ - -This is not a full version of NextUI for macOS. It's a dummy platform to allow using more modern tools to compile and find issues in NextUI's source code without the roundtrip to a device. - -BUILD BATTERY ------------ -cd workspace/all/battery -mkdir -p build/macos - -gcc battery.c -o build/macos/battery -I. -I../common/ -I../../macos/platform/ -I../libbatmondb/ -I/opt/homebrew/include -L/opt/homebrew/lib ../common/scaler.c ../common/utils.c ../common/api.c ../libbatmondb/batmondb.c ../../macos/platform/platform.c -fomit-frame-pointer -DPLATFORM=\"macos\" -DUSE_SDL2 -Ofast -std=gnu99 -ldl -flto -lSDL2 -lSDL2_image -lSDL2_ttf -lpthread -lsqlite3 -lm -lz -fsanitize=address -fno-common -Wno-tautological-constant-out-of-range-compare -Wno-asm-operand-widths -Wno-deprecated-declarations && build/macos/battery \ No newline at end of file diff --git a/workspace/all/battery/makefile b/workspace/all/battery/makefile index ea836b0a2..7b09650ad 100644 --- a/workspace/all/battery/makefile +++ b/workspace/all/battery/makefile @@ -30,11 +30,11 @@ LDFLAGS += -lmsettings -lbatmondb -lsqlite3 PRODUCT= build/$(PLATFORM)/$(TARGET).elf -all: $(PREFIX)/include/batmondb.h +all: $(PREFIX_LOCAL)/include/batmondb.h mkdir -p build/$(PLATFORM) $(CC) $(SOURCE) -o $(PRODUCT) $(CFLAGS) $(LDFLAGS) clean: rm -f $(PRODUCT) -$(PREFIX)/include/batmondb.h: - cd /root/workspace/all/libbatmondb && make \ No newline at end of file +$(PREFIX_LOCAL)/include/batmondb.h: + cd ../libbatmondb && make \ No newline at end of file diff --git a/workspace/all/bootlogo/makefile b/workspace/all/bootlogo/makefile index c83b8be4b..ab5579719 100644 --- a/workspace/all/bootlogo/makefile +++ b/workspace/all/bootlogo/makefile @@ -30,11 +30,11 @@ LDFLAGS += -lmsettings PRODUCT= build/$(PLATFORM)/$(TARGET).elf -all: $(PREFIX)/include/msettings.h +all: $(PREFIX_LOCAL)/include/msettings.h mkdir -p build/$(PLATFORM) $(CC) $(SOURCE) -o $(PRODUCT) $(CFLAGS) $(LDFLAGS) clean: rm -f $(PRODUCT) -$(PREFIX)/include/msettings.h: - cd /root/workspace/$(PLATFORM)/libmsettings && make \ No newline at end of file +$(PREFIX_LOCAL)/include/msettings.h: + cd ../../$(PLATFORM)/libmsettings && make \ No newline at end of file diff --git a/workspace/all/clock/makefile b/workspace/all/clock/makefile index 4f88d4d1f..7dfed90fe 100644 --- a/workspace/all/clock/makefile +++ b/workspace/all/clock/makefile @@ -30,11 +30,11 @@ LDFLAGS += -lmsettings PRODUCT= build/$(PLATFORM)/$(TARGET).elf -all: $(PREFIX)/include/msettings.h +all: $(PREFIX_LOCAL)/include/msettings.h mkdir -p build/$(PLATFORM) $(CC) $(SOURCE) -o $(PRODUCT) $(CFLAGS) $(LDFLAGS) clean: rm -f $(PRODUCT) -$(PREFIX)/include/msettings.h: - cd /root/workspace/$(PLATFORM)/libmsettings && make \ No newline at end of file +$(PREFIX_LOCAL)/include/msettings.h: + cd ../../$(PLATFORM)/libmsettings && make \ No newline at end of file diff --git a/workspace/all/common/api.c b/workspace/all/common/api.c index d40c6fd7e..69006484c 100644 --- a/workspace/all/common/api.c +++ b/workspace/all/common/api.c @@ -761,54 +761,105 @@ struct blend_args { uint16_t *blend_line; } blend_args; -#if __ARM_ARCH >= 5 && !defined(__APPLE__) && !defined(__SNAPDRAGON__) -static inline uint32_t average16(uint32_t c1, uint32_t c2) { - uint32_t ret, lowbits = 0x0821; - asm ("eor %0, %2, %3\r\n" - "and %0, %0, %1\r\n" - "add %0, %3, %0\r\n" - "add %0, %0, %2\r\n" - "lsr %0, %0, #1\r\n" - : "=&r" (ret) : "r" (lowbits), "r" (c1), "r" (c2) : ); - return ret; +// Pure C fallbacks +static inline uint32_t average16_c(uint32_t c1, uint32_t c2) { + return (c1 + c2 + ((c1 ^ c2) & 0x0821))>>1; } -static inline uint32_t average32(uint32_t c1, uint32_t c2) { - uint32_t ret, lowbits = 0x08210821; - asm ("eor %0, %3, %1\r\n" - "and %0, %0, %2\r\n" - "adds %0, %1, %0\r\n" - "and %1, %1, #0\r\n" - "movcs %1, #0x80000000\r\n" - "adds %0, %0, %3\r\n" - "rrx %0, %0\r\n" - "orr %0, %0, %1\r\n" - : "=&r" (ret), "+r" (c2) : "r" (lowbits), "r" (c1) : "cc" ); +static inline uint32_t average32_c(uint32_t c1, uint32_t c2) { + uint32_t sum = c1 + c2; + uint32_t ret = sum + ((c1 ^ c2) & 0x08210821); + uint32_t of = ((sum < c1) | (ret < sum)) << 31; - return ret; + return (ret >> 1) | of; } -#define AVERAGE16_NOCHK(c1, c2) (average16((c1), (c2))) -#define AVERAGE32_NOCHK(c1, c2) (average32((c1), (c2))) - -#else +// not sure we are activating this anywhere currently, but we could. +// to be honest, I'm not sure if we're using this function at all right now, +// but I'm fixing it anyway so might as well improve it. +#ifdef HAS_NEON +// #if defined(__ARM_NEON) || defined(__ARM_NEON__) +static inline uint32x4_t average32_neon(uint32x4_t a, uint32x4_t b) { + return vhaddq_u32(a, b); // vector halving add (a + b) >> 1 +} +#endif +// aarch32 asm +#if defined(__arm__) && !defined(__aarch64__) static inline uint32_t average16(uint32_t c1, uint32_t c2) { - return (c1 + c2 + ((c1 ^ c2) & 0x0821))>>1; + uint32_t ret, lowbits = 0x0821; + asm volatile ( + "eor %0, %2, %3\n\t" + "and %0, %0, %1\n\t" + "add %0, %3, %0\n\t" + "add %0, %0, %2\n\t" + "lsr %0, %0, #1\n\t" + : "=&r" (ret) + : "r" (lowbits), "r" (c1), "r" (c2) + ); + return ret; } + static inline uint32_t average32(uint32_t c1, uint32_t c2) { - uint32_t sum = c1 + c2; - uint32_t ret = sum + ((c1 ^ c2) & 0x08210821); - uint32_t of = ((sum < c1) | (ret < sum)) << 31; + uint32_t ret, lowbits = 0x08210821; + asm volatile ( + "eor %0, %3, %1\n\t" + "and %0, %0, %2\n\t" + "adds %0, %1, %0\n\t" + "and %1, %1, #0\n\t" + "movcs %1, #0x80000000\n\t" + "adds %0, %0, %3\n\t" + "rrx %0, %0\n\t" + "orr %0, %0, %1\n\t" + : "=&r" (ret), "+r" (c2) + : "r" (lowbits), "r" (c1) + : "cc" + ); + return ret; +} + +// aarch64 asm +#elif defined(__aarch64__) - return (ret >> 1) | of; +static inline uint32_t average16(uint32_t c1, uint32_t c2) { + uint32_t result; + asm volatile ( + "and w2, %w0, %w1\n\t" + "eor w3, %w0, %w1\n\t" + "lsr w3, w3, #1\n\t" + "add %w2, w2, w3\n\t" + "mov %w0, w2\n\t" + : "+r"(c1) + : "r"(c2) + : "w2", "w3" + ); + return c1; } +static inline uint32_t average32(uint32_t c1, uint32_t c2) { + uint32_t result; + asm volatile ( + "and w2, %w0, %w1\n\t" + "eor w3, %w0, %w1\n\t" + "lsr w3, w3, #1\n\t" + "add w2, w2, w3\n\t" + "mov %w0, w2\n\t" + : "+r"(c1) + : "r"(c2) + : "w2", "w3" + ); + return c1; +} + +// fallback if nothing else works +#else +#define average16 average16_c +#define average32 average32_c +#endif + #define AVERAGE16_NOCHK(c1, c2) (average16((c1), (c2))) #define AVERAGE32_NOCHK(c1, c2) (average32((c1), (c2))) -#endif - #define AVERAGE16(c1, c2) ((c1) == (c2) ? (c1) : AVERAGE16_NOCHK((c1), (c2))) #define AVERAGE16_1_3(c1, c2) ((c1) == (c2) ? (c1) : (AVERAGE16_NOCHK(AVERAGE16_NOCHK((c1), (c2)), (c2)))) diff --git a/workspace/all/common/api.h b/workspace/all/common/api.h index 9db138a51..87a9d20a3 100644 --- a/workspace/all/common/api.h +++ b/workspace/all/common/api.h @@ -212,7 +212,6 @@ enum { MODE_MAIN, MODE_MENU, }; -#include "opengl.h" #define MAX_PARAM_NAME 128 #define MAX_PARAM_LABEL 128 typedef struct { diff --git a/workspace/all/common/opengl.h b/workspace/all/common/opengl.h deleted file mode 100644 index 3332eda14..000000000 --- a/workspace/all/common/opengl.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef GL_HEADERS_H -#define GL_HEADERS_H - -#ifdef USE_GL -# //pragma message("Compiling with OpenGL") -# include -# include -# define WHICH_GL "OpenGL" -#else -# //pragma message("Compiling with OpenGL ES") -# define GL_GLEXT_PROTOTYPES 1 -# include -# define WHICH_GL "GLESv2" -#endif - -#endif // GL_HEADERS_H \ No newline at end of file diff --git a/workspace/all/common/sdl.h b/workspace/all/common/sdl.h index 6cf438d2f..2907f08ca 100644 --- a/workspace/all/common/sdl.h +++ b/workspace/all/common/sdl.h @@ -4,8 +4,9 @@ #if defined(USE_SDL2) /////////////////////////////// - #include +#include +#include #include #include diff --git a/workspace/all/gametime/makefile b/workspace/all/gametime/makefile index 584f7592c..3dbdda764 100644 --- a/workspace/all/gametime/makefile +++ b/workspace/all/gametime/makefile @@ -30,11 +30,11 @@ LDFLAGS += -lmsettings -lgametimedb -lsqlite3 PRODUCT= build/$(PLATFORM)/$(TARGET).elf -all: $(PREFIX)/include/gametimedb.h +all: $(PREFIX_LOCAL)/include/gametimedb.h mkdir -p build/$(PLATFORM) $(CC) $(SOURCE) -o $(PRODUCT) $(CFLAGS) $(LDFLAGS) clean: rm -f $(PRODUCT) -$(PREFIX)/include/gametimedb.h: - cd /root/workspace/all/libgametimedb && make \ No newline at end of file +$(PREFIX_LOCAL)/include/gametimedb.h: + cd ../libgametimedb && make \ No newline at end of file diff --git a/workspace/all/gametimectl/makefile b/workspace/all/gametimectl/makefile index 9935fdcce..9a9676bad 100644 --- a/workspace/all/gametimectl/makefile +++ b/workspace/all/gametimectl/makefile @@ -21,7 +21,7 @@ SDL?=SDL TARGET = gametimectl INCDIR = -I. -I../common/ -I../../$(PLATFORM)/platform/ -SOURCE = $(TARGET).c ../common/utils.c ../common/api.c ../common/scaler.c ../../$(PLATFORM)/platform/platform.c +SOURCE = $(TARGET).c ../common/utils.c ../common/api.c ../common/scaler.c ../common/config.c ../../$(PLATFORM)/platform/platform.c CC = $(CROSS_COMPILE)gcc CFLAGS += $(ARCH) -fomit-frame-pointer @@ -30,11 +30,11 @@ LDFLAGS += -lmsettings -lgametimedb -lsqlite3 PRODUCT= build/$(PLATFORM)/$(TARGET).elf -all: $(PREFIX)/include/gametimedb.h +all: $(PREFIX_LOCAL)/include/gametimedb.h mkdir -p build/$(PLATFORM) $(CC) $(SOURCE) -o $(PRODUCT) $(CFLAGS) $(LDFLAGS) clean: rm -f $(PRODUCT) -$(PREFIX)/include/gametimedb.h: - cd /root/workspace/all/libgametimedb && make \ No newline at end of file +$(PREFIX_LOCAL)/include/gametimedb.h: + cd ../libgametimedb && make \ No newline at end of file diff --git a/workspace/all/ledcontrol/makefile b/workspace/all/ledcontrol/makefile index 5ad0619bf..8216f4a4d 100644 --- a/workspace/all/ledcontrol/makefile +++ b/workspace/all/ledcontrol/makefile @@ -30,11 +30,11 @@ LDFLAGS += -lmsettings PRODUCT= build/$(PLATFORM)/$(TARGET).elf -all: $(PREFIX)/include/msettings.h +all: $(PREFIX_LOCAL)/include/msettings.h mkdir -p build/$(PLATFORM) $(CC) $(SOURCE) -o $(PRODUCT) $(CFLAGS) $(LDFLAGS) clean: rm -f $(PRODUCT) -$(PREFIX)/include/msettings.h: - cd /root/workspace/$(PLATFORM)/libmsettings && make \ No newline at end of file +$(PREFIX_LOCAL)/include/msettings.h: + cd ../../$(PLATFORM)/libmsettings && make \ No newline at end of file diff --git a/workspace/all/libbatmondb/makefile b/workspace/all/libbatmondb/makefile index d8815091c..15a94b8d4 100644 --- a/workspace/all/libbatmondb/makefile +++ b/workspace/all/libbatmondb/makefile @@ -37,18 +37,19 @@ SOURCE = $(TARGET).c ../common/utils.c ../common/api.c ../../$(PLATFORM)/platfor CFLAGS += $(ARCH) -fomit-frame-pointer CFLAGS += $(INCDIR) -DPLATFORM=\"$(PLATFORM)\" -std=gnu99 -LDFLAGS += -s +LDFLAGS += -s -lsqlite3 PRODUCT= build/$(PLATFORM)/lib$(TARGET).so build: mkdir -p build/$(PLATFORM) $(CC) -c -Werror -fpic $(SOURCE) -Wl,--no-as-needed $(LDFLAGS) $(CFLAGS) - $(CC) -shared -o $(PRODUCT) "$(TARGET).o" $(LDFLAGS) - cp "$(TARGET).h" "$(PREFIX)/include" - cp $(PRODUCT) "$(PREFIX)/lib" + $(CC) -shared -o $(PRODUCT) "$(TARGET).o" "utils.o" $(LDFLAGS) + cp "$(TARGET).h" "$(PREFIX_LOCAL)/include" + cp $(PRODUCT) "$(PREFIX_LOCAL)/lib" + clean: rm -f *.o rm -f $(PRODUCT) - rm -f $(PREFIX)/include/$(TARGET).h - rm -f $(PREFIX)/lib/lib$(TARGET).so \ No newline at end of file + rm -f $(PREFIX_LOCAL)/include/$(TARGET).h + rm -f $(PREFIX_LOCAL)/lib/lib$(TARGET).so \ No newline at end of file diff --git a/workspace/all/libgametimedb/makefile b/workspace/all/libgametimedb/makefile index 394d98e94..b622b6be2 100644 --- a/workspace/all/libgametimedb/makefile +++ b/workspace/all/libgametimedb/makefile @@ -37,18 +37,19 @@ SOURCE = $(TARGET).c ../common/utils.c ../common/api.c ../../$(PLATFORM)/platfor CFLAGS += $(ARCH) -fomit-frame-pointer CFLAGS += $(INCDIR) -DPLATFORM=\"$(PLATFORM)\" -std=gnu99 -LDFLAGS += -s +LDFLAGS += -s -lsqlite3 PRODUCT= build/$(PLATFORM)/lib$(TARGET).so build: mkdir -p build/$(PLATFORM) $(CC) -c -Werror -fpic $(SOURCE) -Wl,--no-as-needed $(LDFLAGS) $(CFLAGS) - $(CC) -shared -o $(PRODUCT) "$(TARGET).o" $(LDFLAGS) - cp "$(TARGET).h" "$(PREFIX)/include" - cp $(PRODUCT) "$(PREFIX)/lib" + $(CC) -shared -o $(PRODUCT) "$(TARGET).o" "utils.o" $(LDFLAGS) + cp "$(TARGET).h" "$(PREFIX_LOCAL)/include" + cp $(PRODUCT) "$(PREFIX_LOCAL)/lib" + clean: rm -f *.o rm -f $(PRODUCT) - rm -f $(PREFIX)/include/$(TARGET).h - rm -f $(PREFIX)/lib/lib$(TARGET).so \ No newline at end of file + rm -f $(PREFIX_LOCAL)/include/$(TARGET).h + rm -f $(PREFIX_LOCAL)/lib/lib$(TARGET).so \ No newline at end of file diff --git a/workspace/all/minarch/makefile b/workspace/all/minarch/makefile index ac273433e..dff1b2651 100644 --- a/workspace/all/minarch/makefile +++ b/workspace/all/minarch/makefile @@ -26,8 +26,20 @@ SOURCE = $(TARGET).c ../common/scaler.c ../common/utils.c ../common/config.c ../ CC = $(CROSS_COMPILE)gcc CFLAGS += $(ARCH) -fomit-frame-pointer -CFLAGS += $(INCDIR) -DPLATFORM=\"$(PLATFORM)\" -O3 -Ofast -std=gnu99 -LDFLAGS += -lmsettings -lzip -lsamplerate -Llibretro-common -lsrm +CFLAGS += $(INCDIR) -DPLATFORM=\"$(PLATFORM)\" -std=gnu99 +LDFLAGS += -lmsettings -lsamplerate +ifeq ($(PLATFORM), tg5040) +LDFLAGS += -Llibretro-common -lsrm -lzip +CFLAGS += -DHAS_SRM +endif +ifeq ($(PLATFORM), desktop) +ifeq ($(UNAME_S),Linux) +CFLAGS += `pkg-config --cflags libzip` +LDFLAGS += `pkg-config --libs libzip` +else +LDFLAGS += -lzip +endif +endif # CFLAGS += -Wall -Wno-unused-variable -Wno-unused-function -Wno-format-overflow # CFLAGS += -fsanitize=address -fno-common # LDFLAGS += -lasan @@ -39,7 +51,12 @@ BUILD_DATE!=date +%Y.%m.%d BUILD_HASH!=cat ../../hash.txt CFLAGS += -DBUILD_DATE=\"${BUILD_DATE}\" -DBUILD_HASH=\"${BUILD_HASH}\" -all: libretro-common libsrm.a $(PREFIX)/include/msettings.h +ifeq ($(PLATFORM), desktop) +all: libretro-common $(PREFIX_LOCAL)/include/msettings.h + mkdir -p build/$(PLATFORM) + $(CC) $(SOURCE) -o $(PRODUCT) $(CFLAGS) $(LDFLAGS) +else +all: libretro-common libsrm.a $(PREFIX_LOCAL)/include/msettings.h mkdir -p build/$(PLATFORM) cp /usr/lib/aarch64-linux-gnu/libsamplerate.so.0 build/$(PLATFORM) # This is a bandaid fix, needs to be cleaned up if/when we expand to other platforms. @@ -48,12 +65,13 @@ all: libretro-common libsrm.a $(PREFIX)/include/msettings.h cp /lib/aarch64-linux-gnu/liblzma.so.5 build/$(PLATFORM) cp /usr/lib/aarch64-linux-gnu/libzstd.so.1 build/$(PLATFORM) $(CC) $(SOURCE) -o $(PRODUCT) $(CFLAGS) $(LDFLAGS) +endif libretro-common: git clone https://github.com/libretro/libretro-common -$(PREFIX)/include/msettings.h: - cd /root/workspace/$(PLATFORM)/libmsettings && make +$(PREFIX_LOCAL)/include/msettings.h: + cd ../../$(PLATFORM)/libmsettings && make ### libsrm stuff OBJECTS = streams/rzip_stream.o streams/file_stream.o vfs/vfs_implementation.o file/file_path.o file/file_path_io.o compat/compat_strl.o time/rtime.o string/stdstring.o encodings/encoding_utf.o streams/trans_stream.o streams/trans_stream_pipe.o streams/trans_stream_zlib.o diff --git a/workspace/all/minarch/minarch.c b/workspace/all/minarch/minarch.c index 323362e7d..3c0711e77 100644 --- a/workspace/all/minarch/minarch.c +++ b/workspace/all/minarch/minarch.c @@ -15,8 +15,10 @@ // libretro-common #include "libretro.h" +#ifdef HAS_SRM #include "streams/rzip_stream.h" #include "streams/file_stream.h" +#endif #include "defines.h" #include "api.h" @@ -630,6 +632,7 @@ static void SRAM_read(void) { void* sram = core.get_memory_data(RETRO_MEMORY_SAVE_RAM); +#ifdef HAS_SRM // TODO: rzipstream_open can also handle uncompressed, else branch is probably unnecessary // srm, potentially compressed if (CFG_getSaveFormat() == SAVE_FORMAT_SRM) { @@ -651,6 +654,14 @@ static void SRAM_read(void) { filestream_close(sram_file); } +#else + FILE *sram_file = fopen(filename, "r"); + if (!sram_file) return; + if (!sram || !fread(sram, 1, sram_size, sram_file)) { + LOG_error("Error reading SRAM data\n"); + } + fclose(sram_file); +#endif } static void SRAM_write(void) { @@ -663,6 +674,7 @@ static void SRAM_write(void) { void *sram = core.get_memory_data(RETRO_MEMORY_SAVE_RAM); +#ifdef HAS_SRM // srm, compressed if (CFG_getSaveFormat() == SAVE_FORMAT_SRM) { if(!rzipstream_write_file(filename, sram, sram_size)) @@ -672,7 +684,17 @@ static void SRAM_write(void) { if(!filestream_write_file(filename, sram, sram_size)) LOG_error("filestream: Error writing SRAM data to file\n"); } - +#else + FILE *sram_file = fopen(filename, "w"); + if (!sram_file) { + LOG_error("Error opening SRAM file: %s\n", strerror(errno)); + return; + } + if (!sram || sram_size != fwrite(sram, 1, sram_size, sram_file)) { + LOG_error("Error writing SRAM data to file\n"); + } + fclose(sram_file); +#endif sync(); } @@ -773,6 +795,7 @@ static void State_read(void) { // from picoarch char filename[MAX_PATH]; State_getPath(filename); +#ifdef HAS_SRM RFILE *state_rfile = NULL; rzipstream_t *state_rzfile = NULL; @@ -825,7 +848,31 @@ static void State_read(void) { // from picoarch if (state) free(state); if (state_rfile) filestream_close(state_rfile); if (state_rzfile) rzipstream_close(state_rzfile); +#else + FILE *state_file = fopen(filename, "r"); + if (!state_file) { + if (state_slot!=8) { // st8 is a default state in MiniUI and may not exist, that's okay + LOG_error("Error opening state file: %s (%s)\n", filename, strerror(errno)); + } + goto error; + } + // some cores report the wrong serialize size initially for some games, eg. mgba: Wario Land 4 + // so we allow a size mismatch as long as the actual size fits in the buffer we've allocated + if (state_size < fread(state, 1, state_size, state_file)) { + LOG_error("Error reading state data from file: %s (%s)\n", filename, strerror(errno)); + goto error; + } + + if (!core.unserialize(state, state_size)) { + LOG_error("Error restoring save state: %s (%s)\n", filename, strerror(errno)); + goto error; + } + +error: + if (state) free(state); + if (state_file) fclose(state_file); +#endif fast_forward = was_ff; } @@ -846,10 +893,10 @@ static void State_write(void) { // from picoarch LOG_error("Error serializing save state\n"); goto error; } - + char filename[MAX_PATH]; State_getPath(filename); - +#ifdef HAS_SRM if (CFG_getStateFormat() == STATE_FORMAT_SRM) { if(!rzipstream_write_file(filename, state, state_size)) { LOG_error("rzipstream: Error writing state data to file: %s\n", filename); @@ -865,9 +912,22 @@ static void State_write(void) { // from picoarch error: if (state) free(state); +#else + FILE *state_file = fopen(filename, "w"); + if (!state_file) { + LOG_error("Error opening state file: %s (%s)\n", filename, strerror(errno)); + goto error; + } + if (state_size != fwrite(state, 1, state_size, state_file)) { + LOG_error("Error writing state data to file: %s (%s)\n", filename, strerror(errno)); + goto error; + } + error: + if (state) free(state); + if (state_file) fclose(state_file); +#endif sync(); - fast_forward = was_ff; } @@ -6712,7 +6772,10 @@ int main(int argc , char* argv[]) { char core_path[MAX_PATH]; char rom_path[MAX_PATH]; char tag_name[MAX_PATH]; - + + if(argc < 2) + return EXIT_FAILURE; + strcpy(core_path, argv[1]); strcpy(rom_path, argv[2]); getEmuName(rom_path, tag_name); diff --git a/workspace/all/minput/makefile b/workspace/all/minput/makefile index 86ff382d0..d50f922a0 100644 --- a/workspace/all/minput/makefile +++ b/workspace/all/minput/makefile @@ -30,11 +30,11 @@ LDFLAGS += -lmsettings PRODUCT= build/$(PLATFORM)/$(TARGET).elf -all: $(PREFIX)/include/msettings.h +all: $(PREFIX_LOCAL)/include/msettings.h mkdir -p build/$(PLATFORM) $(CC) $(SOURCE) -o $(PRODUCT) $(CFLAGS) $(LDFLAGS) clean: rm -f $(PRODUCT) -$(PREFIX)/include/msettings.h: - cd /root/workspace/$(PLATFORM)/libmsettings && make \ No newline at end of file +$(PREFIX_LOCAL)/include/msettings.h: + cd ../../$(PLATFORM)/libmsettings && make \ No newline at end of file diff --git a/workspace/all/nextui/makefile b/workspace/all/nextui/makefile index 4742bf8a6..bdf25f44a 100644 --- a/workspace/all/nextui/makefile +++ b/workspace/all/nextui/makefile @@ -30,11 +30,11 @@ LDFLAGS += -lmsettings PRODUCT= build/$(PLATFORM)/$(TARGET).elf -all: $(PREFIX)/include/msettings.h +all: $(PREFIX_LOCAL)/include/msettings.h mkdir -p build/$(PLATFORM) $(CC) $(SOURCE) -o $(PRODUCT) $(CFLAGS) $(LDFLAGS) clean: rm -f $(PRODUCT) -$(PREFIX)/include/msettings.h: - cd /root/workspace/$(PLATFORM)/libmsettings && make +$(PREFIX_LOCAL)/include/msettings.h: + cd ../../$(PLATFORM)/libmsettings && make diff --git a/workspace/all/settings/makefile b/workspace/all/settings/makefile index 93162608d..cdc4441a5 100644 --- a/workspace/all/settings/makefile +++ b/workspace/all/settings/makefile @@ -30,11 +30,15 @@ CFLAGS += $(ARCH) -fomit-frame-pointer CFLAGS += $(INCDIR) -DPLATFORM=\"$(PLATFORM)\" CXXFLAGS += $(CFLAGS) -std=c++17 CFLAGS += -fpermissive -LDFLAGS += -lmsettings -lwifimg +LDFLAGS += -lmsettings +ifeq ($(PLATFORM), tg5040) +CFLAGS += -DHAS_WIFIMG +LDFLAGS += -lwifimg +endif PRODUCT= build/$(PLATFORM)/$(TARGET).elf -all: $(PREFIX)/include/msettings.h +all: $(PREFIX_LOCAL)/include/msettings.h mkdir -p build/$(PLATFORM) $(CC) $(SOURCE) $(CFLAGS) $(LDFLAGS) mv utils.o api.o config.o scaler.o platform.o build/$(PLATFORM) @@ -42,5 +46,5 @@ all: $(PREFIX)/include/msettings.h clean: rm -f $(PRODUCT) -$(PREFIX)/include/msettings.h: - cd /root/workspace/$(PLATFORM)/libmsettings && make \ No newline at end of file +$(PREFIX_LOCAL)/include/msettings.h: + cd ../../$(PLATFORM)/libmsettings && make \ No newline at end of file diff --git a/workspace/all/settings/menu.cpp b/workspace/all/settings/menu.cpp index ff7a43b10..80e01c31d 100644 --- a/workspace/all/settings/menu.cpp +++ b/workspace/all/settings/menu.cpp @@ -7,6 +7,7 @@ extern "C" #include "utils.h" } +#include #include typedef std::shared_mutex Lock; typedef std::unique_lock< Lock > WriteLock; diff --git a/workspace/all/settings/wifimenu.cpp b/workspace/all/settings/wifimenu.cpp index c1513e711..f8945c3d7 100644 --- a/workspace/all/settings/wifimenu.cpp +++ b/workspace/all/settings/wifimenu.cpp @@ -4,6 +4,7 @@ #include #include +#include #include typedef std::shared_mutex Lock; typedef std::unique_lock WriteLock; diff --git a/workspace/all/syncsettings/makefile b/workspace/all/syncsettings/makefile index 2a9f261d7..12d6e2c4d 100755 --- a/workspace/all/syncsettings/makefile +++ b/workspace/all/syncsettings/makefile @@ -18,16 +18,16 @@ TARGET = syncsettings SOURCE = $(TARGET).c CC = $(CROSS_COMPILE)gcc -CFLAGS = $(ARCH) -DPLATFORM=\"$(PLATFORM)\" +CFLAGS = $(ARCH) -I$(PREFIX_LOCAL)/include -DPLATFORM=\"$(PLATFORM)\" LDFLAGS = -Os -lmsettings -lrt -ldl -Wl,--gc-sections -s PRODUCT= build/$(PLATFORM)/$(TARGET).elf -all: $(PREFIX)/include/msettings.h +all: $(PREFIX_LOCAL)/include/msettings.h mkdir -p build/$(PLATFORM) $(CC) $(SOURCE) -o $(PRODUCT) $(CFLAGS) $(LDFLAGS) clean: rm -f $(PRODUCT) -$(PREFIX)/include/msettings.h: - cd /root/workspace/$(PLATFORM)/libmsettings && make +$(PREFIX_LOCAL)/include/msettings.h: + cd ../../$(PLATFORM)/libmsettings && make diff --git a/workspace/all/syncsettings/syncsettings.c b/workspace/all/syncsettings/syncsettings.c index 735ded783..2bf4c5934 100644 --- a/workspace/all/syncsettings/syncsettings.c +++ b/workspace/all/syncsettings/syncsettings.c @@ -1,6 +1,6 @@ #include #include -#include +#include "msettings.h" int main (int argc, char *argv[]) { InitSettings(); diff --git a/workspace/desktop/cores/makefile b/workspace/desktop/cores/makefile new file mode 100644 index 000000000..71d14c60a --- /dev/null +++ b/workspace/desktop/cores/makefile @@ -0,0 +1,105 @@ +#CORES= c128 +#CORES+= c64 +#CORES+= fake-08 (clang) +#CORES+= fbneo +#CORES+= fceumm (clang) +#CORES+= gambatte +#CORES+= gpsp +#CORES+= libretro-cap32 +#CORES+= libretro-uae +#CORES+= mednafen_pce_fast +#CORES+= mednafen_supafaust +#CORES+= mednafen_vb +#CORES+= mgba +#CORES+= pcsx_rearmed +#CORES+= pet +#CORES+= picodrive (clang) +#CORES+= plus4 +#CORES+= pokemini (clang) +#CORES+= race (clang) +#CORES+= snes9x +#CORES+= vic +#CORES+= prboom + +############################### + +# optional core vars +# *_REPO= +# *_HASH= +# *_CORE= +# *_FLAGS= +# *_MAKEFILE= +# *_BUILD_PATH= +# *_SUBMODULES= + +fbneo_REPO = https://github.com/libretro/FBNeo +fbneo_CORE = fbneo_libretro.so +fbneo_BUILD_PATH = fbneo/src/burner/libretro +fbneo_MAKE = make + +mednafen_pce_fast_REPO = https://github.com/libretro/beetle-pce-fast-libretro +mednafen_vb_REPO = https://github.com/libretro/beetle-vb-libretro + +fake-08_REPO = https://github.com/jtothebell/fake-08 +fake-08_CORE = fake08_libretro.so +fake-08_BUILD_PATH = fake-08/platform/libretro + +fceumm_REPO = https://github.com/libretro/libretro-fceumm + +gambatte_REPO = https://github.com/libretro/gambatte-libretro + +mednafen_supafaust_REPO = https://github.com/libretro/supafaust + +pcsx_rearmed_MAKEFILE = Makefile.libretro +pcsx_rearmed_SUBMODULES = frontend/libpicofe + +picodrive_REPO = https://github.com/irixxxx/picodrive +picodrive_MAKEFILE = Makefile.libretro +# No background Audio on Sega CD +# https://github.com/LoveRetro/NextUI/issues/68 +picodrive_HASH = b0be121 + +pokemini_REPO = https://github.com/libretro/PokeMini +pokemini_MAKEFILE = Makefile.libretro +# Our patchfile doesn't work on latest Pokemon mini commits, pinning to last working hash for now +pokemini_HASH = 78656d4 + +prboom_REPO = https://github.com/libretro/libretro-prboom + +snes9x2005_plus_REPO = https://github.com/libretro/snes9x2005 +snes9x2005_plus_FLAGS = USE_BLARGG_APU=1 + +snes9x_REPO = https://github.com/libretro/snes9x +snes9x_CORE = snes9x_libretro.so +snes9x_BUILD_PATH = snes9x/libretro + +libretro-uae_REPO = https://github.com/libretro/libretro-uae +libretro-uae_HASH = 2.6.1 +libretro-uae_CORE = puae2021_libretro.so + +libretro-cap32_REPO = https://github.com/libretro/libretro-cap32 +libretro-cap32_CORE = cap32_libretro.so + +c64_REPO = https://github.com/libretro/vice-libretro +c64_CORE = vice_x64_libretro.so +c64_FLAGS = EMUTYPE=x64 + +c128_REPO = https://github.com/libretro/vice-libretro +c128_CORE = vice_x128_libretro.so +c128_FLAGS = EMUTYPE=x128 + +vic_REPO = https://github.com/libretro/vice-libretro +vic_CORE = vice_xvic_libretro.so +vic_FLAGS = EMUTYPE=xvic + +pet_REPO = https://github.com/libretro/vice-libretro +pet_CORE = vice_xpet_libretro.so +pet_FLAGS = EMUTYPE=xpet + +plus4_REPO = https://github.com/libretro/vice-libretro +plus4_CORE = vice_xplus4_libretro.so +plus4_FLAGS = EMUTYPE=xplus4 + +############################### + +include ../../all/cores/makefile diff --git a/workspace/desktop/cores/patches/gambatte.patch b/workspace/desktop/cores/patches/gambatte.patch new file mode 100644 index 000000000..c711ce00d --- /dev/null +++ b/workspace/desktop/cores/patches/gambatte.patch @@ -0,0 +1,25 @@ +diff --git forkSrcPrefix/Makefile.libretro forkDstPrefix/Makefile.libretro +index ffaba21e7a88f90786d818ab550b68acd05738bf..2095b2f843eaf6be9abec24ce3da69b551da86a6 100644 +--- forkSrcPrefix/Makefile.libretro ++++ forkDstPrefix/Makefile.libretro +@@ -381,6 +381,19 @@ else ifeq ($(platform), gcw0) + CFLAGS += -fomit-frame-pointer -ffast-math -march=mips32 -mtune=mips32r2 -mhard-float + CXXFLAGS += $(CFLAGS) + ++# NextUI debug ++else ifeq ($(platform), desktop) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CC = $(CROSS_COMPILE)gcc ++ CXX = $(CROSS_COMPILE)g++ ++ AR = $(CROSS_COMPILE)ar ++ # macos ld doesnt understand -Wl or --version-script ++ SHARED := -shared -W ++ LDFLAGS += -fPIC -flto ++ PLATFORM_DEFINES := -DCC_RESAMPLER -DCC_RESAMPLER_NO_HIGHPASS ++ CFLAGS += -march=native ++ CFLAGS += -fomit-frame-pointer -ffast-math -fPIC -flto ++ CXXFLAGS += $(CFLAGS) ++ + # RETROFW + else ifeq ($(platform), retrofw) + TARGET := $(TARGET_NAME)_libretro.so diff --git a/workspace/desktop/libmsettings/makefile b/workspace/desktop/libmsettings/makefile new file mode 100644 index 000000000..fb36915d0 --- /dev/null +++ b/workspace/desktop/libmsettings/makefile @@ -0,0 +1,33 @@ +ifeq (,$(CROSS_COMPILE)) +$(error missing CROSS_COMPILE for this toolchain) +endif +ifeq (,$(PREFIX)) +$(error missing PREFIX for this toolchain) +endif + +TARGET=msettings + +.PHONY: build +.PHONY: clean + +CC = $(CROSS_COMPILE)gcc + +CFLAGS = +#LDFLAGS = -ldl -lrt -s +LDFLAGS = -ldl + +OPTM=-Ofast + +build: + $(CC) -c -Werror -fpic "$(TARGET).c" $(CFLAGS) -Wl,--no-as-needed $(LDFLAGS) + $(CC) -shared -o "lib$(TARGET).so" "$(TARGET).o" $(LDFLAGS) + mkdir -p "$(PREFIX_LOCAL)/include" + mkdir -p "$(PREFIX_LOCAL)/lib" + cp "$(TARGET).h" "$(PREFIX_LOCAL)/include" + cp "lib$(TARGET).so" "$(PREFIX_LOCAL)/lib" + +clean: + rm -f *.o + rm -f "lib$(TARGET).so" + rm -f $(PREFIX_LOCAL)/include/$(TARGET).h + rm -f $(PREFIX_LOCAL)/lib/lib$(TARGET).so \ No newline at end of file diff --git a/workspace/desktop/libmsettings/msettings.c b/workspace/desktop/libmsettings/msettings.c new file mode 100644 index 000000000..ec2751eb9 --- /dev/null +++ b/workspace/desktop/libmsettings/msettings.c @@ -0,0 +1,308 @@ +#include "msettings.h" + +// desktop +#include +#include +#include +#include +//#include +//#include +//#include +//#include +//#include +#include + +// Legacy MinUI settings +typedef struct SettingsV3 { + int version; // future proofing + int brightness; + int headphones; + int speaker; + int mute; + int unused[2]; + int jack; +} SettingsV3; + +// First NextUI settings format +typedef struct SettingsV4 { + int version; // future proofing + int brightness; + int colortemperature; // 0-20 + int headphones; + int speaker; + int mute; + int unused[2]; + int jack; +} SettingsV4; + +// Current NextUI settings format +typedef struct SettingsV5 { + int version; // future proofing + int brightness; + int colortemperature; + int headphones; + int speaker; + int mute; + int unused[2]; // for future use + // NOTE: doesn't really need to be persisted but still needs to be shared + int jack; +} SettingsV5; + + +// Third NextUI settings format +typedef struct SettingsV6 { + int version; // future proofing + int brightness; + int colortemperature; + int headphones; + int speaker; + int mute; + int contrast; + int saturation; + int exposure; + int unused[2]; // for future use + // NOTE: doesn't really need to be persisted but still needs to be shared + int jack; +} SettingsV6; + +typedef struct SettingsV7 { + int version; // future proofing + int brightness; + int colortemperature; + int headphones; + int speaker; + int mute; + int contrast; + int saturation; + int exposure; + int mutedbrightness; + int mutedcolortemperature; + int mutedcontrast; + int mutedsaturation; + int mutedexposure; + int unused[2]; // for future use + // NOTE: doesn't really need to be persisted but still needs to be shared + int jack; +} SettingsV7; + +typedef struct SettingsV8 { + int version; // future proofing + int brightness; + int colortemperature; + int headphones; + int speaker; + int mute; + int contrast; + int saturation; + int exposure; + int toggled_brightness; + int toggled_colortemperature; + int toggled_contrast; + int toggled_saturation; + int toggled_exposure; + int toggled_volume; + int unused[2]; // for future use + // NOTE: doesn't really need to be persisted but still needs to be shared + int jack; +} SettingsV8; + +// When incrementing SETTINGS_VERSION, update the Settings typedef and add +// backwards compatibility to InitSettings! +#define SETTINGS_VERSION 8 +typedef SettingsV8 Settings; +static Settings DefaultSettings = { + .version = SETTINGS_VERSION, + .brightness = SETTINGS_DEFAULT_BRIGHTNESS, + .colortemperature = SETTINGS_DEFAULT_COLORTEMP, + .headphones = SETTINGS_DEFAULT_HEADPHONE_VOLUME, + .speaker = SETTINGS_DEFAULT_VOLUME, + .mute = 0, + .contrast = SETTINGS_DEFAULT_CONTRAST, + .saturation = SETTINGS_DEFAULT_SATURATION, + .exposure = SETTINGS_DEFAULT_EXPOSURE, + .toggled_brightness = SETTINGS_DEFAULT_MUTE_NO_CHANGE, + .toggled_colortemperature = SETTINGS_DEFAULT_MUTE_NO_CHANGE, + .toggled_contrast = SETTINGS_DEFAULT_MUTE_NO_CHANGE, + .toggled_saturation = SETTINGS_DEFAULT_MUTE_NO_CHANGE, + .toggled_exposure = SETTINGS_DEFAULT_MUTE_NO_CHANGE, + .toggled_volume = 0, // mute is default + .jack = 0, +}; +static Settings* msettings; + +static char SettingsPath[256]; + +/////////////////////////////////////// + +int peekVersion(const char *filename) { + int version = 0; + FILE *file = fopen(filename, "r"); + if (file) { + fread(&version, sizeof(int), 1, file); + fclose(file); + } + return version; +} + +void InitSettings(void){ + // We are not really using them, but we should be able to debug them + sprintf(SettingsPath, "%s/msettings.bin", getenv("USERDATA_PATH")); + //sprintf(SettingsPath, "%s/msettings.bin", SDCARD_PATH "/.userdata"); + msettings = (Settings*)malloc(sizeof(Settings)); + + int version = peekVersion(SettingsPath); + if(version > 0) { + // fopen file pointer + int fd = open(SettingsPath, O_RDONLY); + if(fd) { + if (version == SETTINGS_VERSION) { + read(fd, msettings, sizeof(Settings)); + } + else if(version==7) { + SettingsV7 old; + read(fd, &old, sizeof(SettingsV7)); + // default muted + msettings->toggled_volume = 0; + // muted* -> toggled* + msettings->toggled_brightness = old.mutedbrightness; + msettings->toggled_colortemperature = old.mutedcolortemperature; + msettings->toggled_contrast = old.mutedcontrast; + msettings->toggled_exposure = old.mutedexposure; + msettings->toggled_saturation = old.mutedsaturation; + // copy the rest + msettings->saturation = old.saturation; + msettings->contrast = old.contrast; + msettings->exposure = old.exposure; + msettings->colortemperature = old.colortemperature; + msettings->brightness = old.brightness; + msettings->headphones = old.headphones; + msettings->speaker = old.speaker; + msettings->mute = old.mute; + msettings->jack = old.jack; + } + else if(version==6) { + SettingsV6 old; + read(fd, &old, sizeof(SettingsV6)); + // no muted* settings yet, default values used. + msettings->toggled_brightness = SETTINGS_DEFAULT_MUTE_NO_CHANGE; + msettings->toggled_colortemperature = SETTINGS_DEFAULT_MUTE_NO_CHANGE; + msettings->toggled_contrast = SETTINGS_DEFAULT_MUTE_NO_CHANGE; + msettings->toggled_exposure = SETTINGS_DEFAULT_MUTE_NO_CHANGE; + msettings->toggled_saturation = SETTINGS_DEFAULT_MUTE_NO_CHANGE; + // copy the rest + msettings->saturation = old.saturation; + msettings->contrast = old.contrast; + msettings->exposure = old.exposure; + msettings->colortemperature = old.colortemperature; + msettings->brightness = old.brightness; + msettings->headphones = old.headphones; + msettings->speaker = old.speaker; + msettings->mute = old.mute; + msettings->jack = old.jack; + } + else if(version==5) { + SettingsV5 old; + read(fd, &old, sizeof(SettingsV5)); + // no display settings yet, default values used. + msettings->saturation = 0; + msettings->contrast = 0; + msettings->exposure = 0; + // copy the rest + msettings->colortemperature = old.colortemperature; + msettings->brightness = old.brightness; + msettings->headphones = old.headphones; + msettings->speaker = old.speaker; + msettings->mute = old.mute; + msettings->jack = old.jack; + } + else if(version==4) { + printf("Found settings v4.\n"); + SettingsV4 old; + // read old settings from fd + read(fd, &old, sizeof(SettingsV4)); + // colortemp was 0-20 here + msettings->colortemperature = old.colortemperature * 2; + } + else if(version==3) { + printf("Found settings v3.\n"); + SettingsV3 old; + read(fd, &old, sizeof(SettingsV3)); + // no colortemp setting yet, default value used. + // copy the rest + msettings->brightness = old.brightness; + msettings->headphones = old.headphones; + msettings->speaker = old.speaker; + msettings->mute = old.mute; + msettings->jack = old.jack; + msettings->colortemperature = 20; + } + else { + printf("Found unsupported settings version: %i.\n", version); + // load defaults + memcpy(msettings, &DefaultSettings, sizeof(Settings)); + } + + close(fd); + } + else { + printf("Unable to read settings, using defaults\n"); + // load defaults + memcpy(msettings, &DefaultSettings, sizeof(Settings)); + } + } + else { + printf("No settings found, using defaults\n"); + // load defaults + memcpy(msettings, &DefaultSettings, sizeof(Settings)); + } +} +void QuitSettings(void){ + // dealloc settings + free(msettings); + msettings = NULL; +} +int InitializedSettings(void) +{ + return msettings != NULL; +} + +// not implemented here + +int GetBrightness(void) { return 0; } +int GetColortemp(void) { return 0; } +int GetContrast(void) { return 0; } +int GetSaturation(void) { return 0; } +int GetExposure(void) { return 0; } +int GetVolume(void) { return 0; } + +int GetMutedBrightness(void) { return 0; } +int GetMutedColortemp(void) { return 0; } +int GetMutedContrast(void) { return 0; } +int GetMutedSaturation(void) { return 0; } +int GetMutedExposure(void) { return 0; } +int GetMutedVolume(void) { return 0; } + +void SetMutedBrightness(int value){} +void SetMutedColortemp(int value){} +void SetMutedContrast(int value){} +void SetMutedSaturation(int value){} +void SetMutedExposure(int value){} +void SetMutedVolume(int value){} + +void SetRawBrightness(int value) {} +void SetRawVolume(int value){} + +void SetBrightness(int value) {} +void SetColortemp(int value) {} +void SetContrast(int value) {} +void SetSaturation(int value) {} +void SetExposure(int value) {} +void SetVolume(int value) {} + +int GetJack(void) { return 0; } +void SetJack(int value) {} + +int GetHDMI(void) { return 0; } +void SetHDMI(int value) {} + +int GetMute(void) { return 0; } \ No newline at end of file diff --git a/workspace/macos/platform/msettings.h b/workspace/desktop/libmsettings/msettings.h similarity index 100% rename from workspace/macos/platform/msettings.h rename to workspace/desktop/libmsettings/msettings.h diff --git a/workspace/desktop/macos_create_gcc_symlinks.sh b/workspace/desktop/macos_create_gcc_symlinks.sh new file mode 100755 index 000000000..79a32558e --- /dev/null +++ b/workspace/desktop/macos_create_gcc_symlinks.sh @@ -0,0 +1,132 @@ +#!/bin/bash + +# Check if script is run with sudo +if [ "$EUID" -ne 0 ]; then + echo "Please run as root (use sudo)" + exit 1 +fi + +# Preserve the original user's environment for brew command +if [ ! -z "$SUDO_USER" ]; then + BREW_PATH=$(sudo -u "$SUDO_USER" which brew) + if [ -z "$BREW_PATH" ]; then + echo "Error: Homebrew not found in $SUDO_USER's environment" + exit 1 + fi +else + echo "Error: SUDO_USER not set. Please run with sudo." + exit 1 +fi + +# Directory settings +TARGET_DIR="/usr/local/bin" + +# Find GCC installation using the original user's brew +if ! GCC_BASE=$(sudo -u "$SUDO_USER" "$BREW_PATH" --prefix gcc 2>/dev/null); then + echo "Error: GCC is not installed via Homebrew" + exit 1 +fi + +GCC_BIN_DIR="$GCC_BASE/bin" + +if [ ! -d "$GCC_BIN_DIR" ]; then + echo "Error: GCC binary directory not found at $GCC_BIN_DIR" + exit 1 +fi + +echo "Using GCC binaries from: $GCC_BIN_DIR" + +# Ensure target directory exists +if [ ! -d "$TARGET_DIR" ]; then + echo "Creating directory $TARGET_DIR..." + mkdir -p "$TARGET_DIR" + chmod 755 "$TARGET_DIR" +fi + +# Function to create a symlink for a GCC tool +create_symlink() { + local source_file="$1" + local target_name="$2" # Now accepts an optional specific target name + local source_name=$(basename "$source_file") + + # Skip architecture-specific tools + if [[ "$source_name" == aarch64-apple-darwin* ]]; then + return 0 + fi + + # If no specific target name provided, generate it from source name + if [ -z "$target_name" ]; then + if [[ $source_name =~ ^(.*)-[0-9]+$ ]]; then + target_name="${BASH_REMATCH[1]}" + else + target_name="$source_name" + fi + fi + + local target_path="$TARGET_DIR/$target_name" + + # Check if source exists and is executable + if [ ! -x "$source_file" ]; then + echo "Error: Source file $source_file is not executable or doesn't exist" + return 1 + fi + + # Handle existing symlink + if [ -L "$target_path" ]; then + local current_target=$(readlink "$target_path") + if [ "$current_target" = "$source_file" ]; then + echo "Skipping $target_name: Link already exists and points to correct target" + return 0 + else + echo "Removing existing symlink $target_path..." + rm "$target_path" + fi + elif [ -e "$target_path" ]; then + echo "Error: $target_path exists and is not a symlink" + return 1 + fi + + # Create new symlink + echo "Creating symlink: $target_name -> $source_file" + ln -s "$source_file" "$target_path" + + # Verify symlink + if [ ! -L "$target_path" ] || [ ! -x "$target_path" ]; then + echo "Error: Failed to create working symlink for $target_name" + return 1 + fi +} + +# Clean up existing directory +rm -f "$TARGET_DIR"/* + +# Process GCC tools +echo "Processing GCC tools from $GCC_BIN_DIR..." + +# Find and process all versioned GCC tools +for tool in "$GCC_BIN_DIR"/*-[0-9]*; do + # Skip non-existent files (in case no matches found) + [ -e "$tool" ] || continue + + # Skip if not a regular file or not executable + [ -f "$tool" ] && [ -x "$tool" ] || continue + + create_symlink "$tool" + + # Special case for gcc-ar: create additional 'ar' symlink + if [[ $(basename "$tool") == "gcc-ar-14" ]]; then + create_symlink "$tool" "ar" + fi +done + +# Special case for gfortran (which might not have version suffix) +if [ -x "$GCC_BIN_DIR/gfortran" ]; then + create_symlink "$GCC_BIN_DIR/gfortran" +fi + +echo "Finished creating symlinks" + +# Final verification +echo "Verifying created symlinks..." +ls -l "$TARGET_DIR" + diff --git a/workspace/desktop/makefile b/workspace/desktop/makefile new file mode 100644 index 000000000..67b7a37e0 --- /dev/null +++ b/workspace/desktop/makefile @@ -0,0 +1,19 @@ +########################################################### + +ifeq (,$(PLATFORM)) +PLATFORM=$(UNION_PLATFORM) +endif + +ifeq (,$(PLATFORM)) +$(error please specify PLATFORM, eg. PLATFORM=desktop make) +endif + +########################################################### + +all: readmes + +early: + +clean: + +include ../all/readmes/makefile diff --git a/workspace/macos/platform/makefile.copy b/workspace/desktop/platform/makefile.copy similarity index 100% rename from workspace/macos/platform/makefile.copy rename to workspace/desktop/platform/makefile.copy diff --git a/workspace/desktop/platform/makefile.env b/workspace/desktop/platform/makefile.env new file mode 100644 index 000000000..ccbf35df4 --- /dev/null +++ b/workspace/desktop/platform/makefile.env @@ -0,0 +1,42 @@ +# desktop +ARCH = -g +CFLAGS = -flto=auto +SDL = SDL2 +GL = GL + +# legacy linux paths +CFLAGS += -I$(PREFIX)/include -I$(PREFIX_LOCAL)/include +LDFLAGS = -L$(PREFIX)/lib -L$(PREFIX_LOCAL)/lib + +# dependencies +CFLAGS += -DUSE_$(SDL) +LDFLAGS += -lpthread -ldl -lm -lz + +# platform dependencies +ifeq ($(UNAME_S),Linux) + # pkg-config + CFLAGS += `pkg-config --cflags sdl2 SDL2_image SDL2_ttf` + LDFLAGS += `pkg-config --libs sdl2 SDL2_image SDL2_ttf` + # opengl + CFLAGS += -DUSE_$(GL) -DGL_GLEXT_PROTOTYPES + LDFLAGS += -lGL + # silence some warnings for now, we'll sort those later + CFLAGS += -Wno-format-overflow -Wno-format-truncation -Wno-format-zero-length -Wno-format-extra-args -Wno-format +endif + +ifeq ($(UNAME_S),Darwin) + # sdl + LDFLAGS += -l$(SDL) -l$(SDL)_image -l$(SDL)_ttf + # opengl + CFLAGS += -DUSE_$(GL) -DGL_GLEXT_PROTOTYPES + LDFLAGS += -framework OpenGL + # sqlite + CFLAGS += -I/opt/homebrew/opt/sqlite/include + LDFLAGS += -L/opt/homebrew/opt/sqlite/lib +endif + +# we have some super old opengl code that throws warnings a lot +CFLAGS += -DGL_SILENCE_DEPRECATION +# TODO: this shouldnt be necessary. +# move resampling code out of api.c +LDFLAGS += -lsamplerate \ No newline at end of file diff --git a/workspace/macos/platform/platform.c b/workspace/desktop/platform/platform.c similarity index 88% rename from workspace/macos/platform/platform.c rename to workspace/desktop/platform/platform.c index 6c81d94a1..b025bb204 100644 --- a/workspace/macos/platform/platform.c +++ b/workspace/desktop/platform/platform.c @@ -9,8 +9,9 @@ #include #include #include +#include -#include "msettings.h" +#include #include "defines.h" #include "platform.h" @@ -18,7 +19,6 @@ #include "utils.h" #include "scaler.h" -#include "opengl.h" #include @@ -65,298 +65,6 @@ Shader* shaders[MAXSHADERS] = { static int nrofshaders = 0; // choose between 1 and 3 pipelines, > pipelines = more cpu usage, but more shader options and shader upscaling stuff -// Legacy MinUI settings -typedef struct SettingsV3 { - int version; // future proofing - int brightness; - int headphones; - int speaker; - int mute; - int unused[2]; - int jack; -} SettingsV3; - -// First NextUI settings format -typedef struct SettingsV4 { - int version; // future proofing - int brightness; - int colortemperature; // 0-20 - int headphones; - int speaker; - int mute; - int unused[2]; - int jack; -} SettingsV4; - -// Current NextUI settings format -typedef struct SettingsV5 { - int version; // future proofing - int brightness; - int colortemperature; - int headphones; - int speaker; - int mute; - int unused[2]; // for future use - // NOTE: doesn't really need to be persisted but still needs to be shared - int jack; -} SettingsV5; - - -// Third NextUI settings format -typedef struct SettingsV6 { - int version; // future proofing - int brightness; - int colortemperature; - int headphones; - int speaker; - int mute; - int contrast; - int saturation; - int exposure; - int unused[2]; // for future use - // NOTE: doesn't really need to be persisted but still needs to be shared - int jack; -} SettingsV6; - -typedef struct SettingsV7 { - int version; // future proofing - int brightness; - int colortemperature; - int headphones; - int speaker; - int mute; - int contrast; - int saturation; - int exposure; - int mutedbrightness; - int mutedcolortemperature; - int mutedcontrast; - int mutedsaturation; - int mutedexposure; - int unused[2]; // for future use - // NOTE: doesn't really need to be persisted but still needs to be shared - int jack; -} SettingsV7; - -typedef struct SettingsV8 { - int version; // future proofing - int brightness; - int colortemperature; - int headphones; - int speaker; - int mute; - int contrast; - int saturation; - int exposure; - int toggled_brightness; - int toggled_colortemperature; - int toggled_contrast; - int toggled_saturation; - int toggled_exposure; - int toggled_volume; - int unused[2]; // for future use - // NOTE: doesn't really need to be persisted but still needs to be shared - int jack; -} SettingsV8; - -// When incrementing SETTINGS_VERSION, update the Settings typedef and add -// backwards compatibility to InitSettings! -#define SETTINGS_VERSION 8 -typedef SettingsV8 Settings; -static Settings DefaultSettings = { - .version = SETTINGS_VERSION, - .brightness = SETTINGS_DEFAULT_BRIGHTNESS, - .colortemperature = SETTINGS_DEFAULT_COLORTEMP, - .headphones = SETTINGS_DEFAULT_HEADPHONE_VOLUME, - .speaker = SETTINGS_DEFAULT_VOLUME, - .mute = 0, - .contrast = SETTINGS_DEFAULT_CONTRAST, - .saturation = SETTINGS_DEFAULT_SATURATION, - .exposure = SETTINGS_DEFAULT_EXPOSURE, - .toggled_brightness = SETTINGS_DEFAULT_MUTE_NO_CHANGE, - .toggled_colortemperature = SETTINGS_DEFAULT_MUTE_NO_CHANGE, - .toggled_contrast = SETTINGS_DEFAULT_MUTE_NO_CHANGE, - .toggled_saturation = SETTINGS_DEFAULT_MUTE_NO_CHANGE, - .toggled_exposure = SETTINGS_DEFAULT_MUTE_NO_CHANGE, - .toggled_volume = 0, // mute is default - .jack = 0, -}; -static Settings* msettings; - -static char SettingsPath[256]; - -/////////////////////////////////////// - -int peekVersion(const char *filename) { - int version = 0; - FILE *file = fopen(filename, "r"); - if (file) { - fread(&version, sizeof(int), 1, file); - fclose(file); - } - return version; -} - -void InitSettings(void){ - // We are not really using them, but we should be able to debug them - sprintf(SettingsPath, "%s/msettings.bin", SDCARD_PATH "/.userdata"); - msettings = (Settings*)malloc(sizeof(Settings)); - - int version = peekVersion(SettingsPath); - if(version > 0) { - // fopen file pointer - int fd = open(SettingsPath, O_RDONLY); - if(fd) { - if (version == SETTINGS_VERSION) { - read(fd, msettings, sizeof(Settings)); - } - else if(version==7) { - SettingsV7 old; - read(fd, &old, sizeof(SettingsV7)); - // default muted - msettings->toggled_volume = 0; - // muted* -> toggled* - msettings->toggled_brightness = old.mutedbrightness; - msettings->toggled_colortemperature = old.mutedcolortemperature; - msettings->toggled_contrast = old.mutedcontrast; - msettings->toggled_exposure = old.mutedexposure; - msettings->toggled_saturation = old.mutedsaturation; - // copy the rest - msettings->saturation = old.saturation; - msettings->contrast = old.contrast; - msettings->exposure = old.exposure; - msettings->colortemperature = old.colortemperature; - msettings->brightness = old.brightness; - msettings->headphones = old.headphones; - msettings->speaker = old.speaker; - msettings->mute = old.mute; - msettings->jack = old.jack; - } - else if(version==6) { - SettingsV6 old; - read(fd, &old, sizeof(SettingsV6)); - // no muted* settings yet, default values used. - msettings->toggled_brightness = SETTINGS_DEFAULT_MUTE_NO_CHANGE; - msettings->toggled_colortemperature = SETTINGS_DEFAULT_MUTE_NO_CHANGE; - msettings->toggled_contrast = SETTINGS_DEFAULT_MUTE_NO_CHANGE; - msettings->toggled_exposure = SETTINGS_DEFAULT_MUTE_NO_CHANGE; - msettings->toggled_saturation = SETTINGS_DEFAULT_MUTE_NO_CHANGE; - // copy the rest - msettings->saturation = old.saturation; - msettings->contrast = old.contrast; - msettings->exposure = old.exposure; - msettings->colortemperature = old.colortemperature; - msettings->brightness = old.brightness; - msettings->headphones = old.headphones; - msettings->speaker = old.speaker; - msettings->mute = old.mute; - msettings->jack = old.jack; - } - else if(version==5) { - SettingsV5 old; - read(fd, &old, sizeof(SettingsV5)); - // no display settings yet, default values used. - msettings->saturation = 0; - msettings->contrast = 0; - msettings->exposure = 0; - // copy the rest - msettings->colortemperature = old.colortemperature; - msettings->brightness = old.brightness; - msettings->headphones = old.headphones; - msettings->speaker = old.speaker; - msettings->mute = old.mute; - msettings->jack = old.jack; - } - else if(version==4) { - printf("Found settings v4.\n"); - SettingsV4 old; - // read old settings from fd - read(fd, &old, sizeof(SettingsV4)); - // colortemp was 0-20 here - msettings->colortemperature = old.colortemperature * 2; - } - else if(version==3) { - printf("Found settings v3.\n"); - SettingsV3 old; - read(fd, &old, sizeof(SettingsV3)); - // no colortemp setting yet, default value used. - // copy the rest - msettings->brightness = old.brightness; - msettings->headphones = old.headphones; - msettings->speaker = old.speaker; - msettings->mute = old.mute; - msettings->jack = old.jack; - msettings->colortemperature = 20; - } - else { - printf("Found unsupported settings version: %i.\n", version); - // load defaults - memcpy(msettings, &DefaultSettings, sizeof(Settings)); - } - - close(fd); - } - else { - printf("Unable to read settings, using defaults\n"); - // load defaults - memcpy(msettings, &DefaultSettings, sizeof(Settings)); - } - } - else { - printf("No settings found, using defaults\n"); - // load defaults - memcpy(msettings, &DefaultSettings, sizeof(Settings)); - } -} -void QuitSettings(void){ - // dealloc settings - free(msettings); - msettings = NULL; -} -int InitializedSettings(void) -{ - return msettings != NULL; -} - -int GetBrightness(void) { return 0; } -int GetColortemp(void) { return 0; } -int GetContrast(void) { return 0; } -int GetSaturation(void) { return 0; } -int GetExposure(void) { return 0; } -int GetVolume(void) { return 0; } - -int GetMutedBrightness(void) { return 0; } -int GetMutedColortemp(void) { return 0; } -int GetMutedContrast(void) { return 0; } -int GetMutedSaturation(void) { return 0; } -int GetMutedExposure(void) { return 0; } -int GetMutedVolume(void) { return 0; } - -void SetMutedBrightness(int value){} -void SetMutedColortemp(int value){} -void SetMutedContrast(int value){} -void SetMutedSaturation(int value){} -void SetMutedExposure(int value){} -void SetMutedVolume(int value){} - -void SetRawBrightness(int value) {} -void SetRawVolume(int value){} - -void SetBrightness(int value) {} -void SetColortemp(int value) {} -void SetContrast(int value) {} -void SetSaturation(int value) {} -void SetExposure(int value) {} -void SetVolume(int value) {} - -int GetJack(void) { return 0; } -void SetJack(int value) {} - -int GetHDMI(void) { return 0; } -void SetHDMI(int value) {} - -int GetMute(void) { return 0; } - /////////////////////////////// static SDL_Joystick *joystick; @@ -552,15 +260,15 @@ GLuint load_shader_from_file(GLenum type, const char* filename, const char* path define = "#define VERTEX\n"; } else if (type == GL_FRAGMENT_SHADER) { define = "#define FRAGMENT\n"; - default_precision = - "#ifdef GL_ES\n" - "#ifdef GL_FRAGMENT_PRECISION_HIGH\n" - "precision highp float;\n" - "#else\n" - "precision mediump float;\n" - "#endif\n" - "#endif\n" - "#define PARAMETER_UNIFORM\n"; + //default_precision = + // "#ifdef GL_ES\n" + // "#ifdef GL_FRAGMENT_PRECISION_HIGH\n" + // "precision highp float;\n" + // "#else\n" + // "precision mediump float;\n" + // "#endif\n" + // "#endif\n" + // "#define PARAMETER_UNIFORM\n"; } else { fprintf(stderr, "Unsupported shader type\n"); free(source); @@ -570,8 +278,8 @@ GLuint load_shader_from_file(GLenum type, const char* filename, const char* path const char* version_start = strstr(source, "#version"); const char* version_end = version_start ? strchr(version_start, '\n') : NULL; - const char* replacement_version = "#version 300 es\n"; - const char* fallback_version = "#version 100\n"; + const char* replacement_version = "#version 120\n"; + const char* fallback_version = "#version 120\n"; char* combined = NULL; size_t define_len = strlen(define); @@ -580,7 +288,7 @@ GLuint load_shader_from_file(GLenum type, const char* filename, const char* path size_t combined_len = 0; // Helper: check if the version is one of the desktop ones to upgrade - int should_replace_with_300es = 0; + int should_replace = 0; if (version_start && version_end) { char version_str[32] = {0}; size_t len = version_end - version_start; @@ -589,27 +297,27 @@ GLuint load_shader_from_file(GLenum type, const char* filename, const char* path version_str[len] = '\0'; // Check for desktop GLSL versions that should be replaced - if ( - strstr(version_str, "#version 110") || - strstr(version_str, "#version 120") || - strstr(version_str, "#version 130") || - strstr(version_str, "#version 140") || - strstr(version_str, "#version 150") || - strstr(version_str, "#version 330") || - strstr(version_str, "#version 400") || - strstr(version_str, "#version 410") || - strstr(version_str, "#version 420") || - strstr(version_str, "#version 430") || - strstr(version_str, "#version 440") || - strstr(version_str, "#version 450") - ) { - should_replace_with_300es = 1; - } + //if ( + // strstr(version_str, "#version 110") || + // strstr(version_str, "#version 120") || + // strstr(version_str, "#version 130") || + // strstr(version_str, "#version 140") || + // strstr(version_str, "#version 150") || + // strstr(version_str, "#version 330") || + // strstr(version_str, "#version 400") || + // strstr(version_str, "#version 410") || + // strstr(version_str, "#version 420") || + // strstr(version_str, "#version 430") || + // strstr(version_str, "#version 440") || + // strstr(version_str, "#version 450") + //) { + // should_replace = 1; + //} } } - if (version_start && version_end && should_replace_with_300es) { - // Replace old desktop version with 300 es + if (version_start && version_end && should_replace) { + // Replace old desktop version with replacement version size_t header_len = version_end - source + 1; size_t version_len = strlen(replacement_version); combined_len = version_len + define_len + precision_len + (source_len - header_len) + 1; @@ -674,6 +382,9 @@ GLuint load_shader_from_file(GLenum type, const char* filename, const char* path glDeleteShader(shader); return 0; } + else{ + fprintf(stdout, "Shader compilation successful\n"); + } return shader; } @@ -701,8 +412,8 @@ void PLAT_initShaders() { } SDL_Surface* PLAT_initVideo(void) { - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); //SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); @@ -763,6 +474,8 @@ SDL_Surface* PLAT_initVideo(void) { SDL_GL_MakeCurrent(vid.window, vid.gl_context); glViewport(0, 0, w, h); + LOG_info("OpenGL version: %s\n", (char *)glGetString(GL_VERSION)); + vid.stream_layer1 = SDL_CreateTexture(vid.renderer,SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING, w,h); vid.target_layer1 = SDL_CreateTexture(vid.renderer,SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET , w,h); vid.target_layer2 = SDL_CreateTexture(vid.renderer,SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET , w,h); diff --git a/workspace/macos/platform/platform.h b/workspace/desktop/platform/platform.h similarity index 89% rename from workspace/macos/platform/platform.h rename to workspace/desktop/platform/platform.h index 218f2f536..beff4ed88 100644 --- a/workspace/macos/platform/platform.h +++ b/workspace/desktop/platform/platform.h @@ -39,18 +39,18 @@ // see https://wiki.libsdl.org/SDL2/SDL_Scancode -#define CODE_UP 82 -#define CODE_DOWN 81 -#define CODE_LEFT 80 -#define CODE_RIGHT 79 +#define CODE_UP 82 // Up Arrow +#define CODE_DOWN 81 // Down Arrow +#define CODE_LEFT 80 // Left Arrow +#define CODE_RIGHT 79 // Right Arrow -#define CODE_SELECT 53 -#define CODE_START 40 +#define CODE_SELECT 53 // ^ +#define CODE_START 40 // Return -#define CODE_A 22 -#define CODE_B 4 -#define CODE_X 26 -#define CODE_Y 20 +#define CODE_A 22 // S +#define CODE_B 4 // A +#define CODE_X 26 // W +#define CODE_Y 20 // Q #define CODE_L1 CODE_NA #define CODE_R1 CODE_NA @@ -59,8 +59,8 @@ #define CODE_L3 CODE_NA #define CODE_R3 CODE_NA -#define CODE_MENU 44 -#define CODE_POWER 42 +#define CODE_MENU 44 // Space +#define CODE_POWER 42 // Backspace #define CODE_PLUS CODE_NA #define CODE_MINUS CODE_NA diff --git a/workspace/macos/notes.txt b/workspace/macos/notes.txt deleted file mode 100644 index a3f14623a..000000000 --- a/workspace/macos/notes.txt +++ /dev/null @@ -1,8 +0,0 @@ -This is not a full version of NextUI for macOS. It's a dummy platform to allow using more modern tools to compile and find issues in NextUI's source code without the roundtrip to a device. - -BUILD NEXTUI ------------- -cd workspace/all/nextui -mkdir -p build/macos - -gcc nextui.c -o build/macos/nextui -I. -I../common/ -I../../macos/platform/ -I/opt/homebrew/include -L/opt/homebrew/lib ../common/scaler.c ../common/utils.c ../common/api.c ../../macos/platform/platform.c -fomit-frame-pointer -DPLATFORM=\"macos\" -DUSE_SDL2 -Ofast -std=gnu99 -ldl -flto -lSDL2 -lSDL2_image -lSDL2_ttf -lpthread -lm -lz -fsanitize=address -fno-common -Wno-tautological-constant-out-of-range-compare -Wno-asm-operand-widths && build/macos/nextui diff --git a/workspace/macos/platform/makefile.env b/workspace/macos/platform/makefile.env deleted file mode 100644 index feeb3fcaa..000000000 --- a/workspace/macos/platform/makefile.env +++ /dev/null @@ -1,13 +0,0 @@ -# tg5040 -ARCH = -O3 -LIBS = -flto -SDL = SDL2 -GL = GL -CFLAGS += -DUSE_$(GL) - -UNAME_S := $(shell uname -s) -ifeq ($(UNAME_S),Darwin) - LIBS += -framework OpenGL -else - LIBS += -lGL -endif \ No newline at end of file diff --git a/workspace/makefile b/workspace/makefile index c9f754ed0..21c73cc53 100644 --- a/workspace/makefile +++ b/workspace/makefile @@ -15,6 +15,22 @@ endif .PHONY: all all: +ifeq ($(PLATFORM), desktop) + cd ./$(PLATFORM)/libmsettings && make + cd ./$(PLATFORM) && make early # eg. other libs + cd ./all/nextui/ && make + cd ./all/minarch/ && make + cd ./all/battery/ && make + cd ./all/clock/ && make + cd ./all/libbatmondb/ && make + cd ./all/batmon/ && make + cd ./all/libgametimedb/ && make + cd ./all/gametimectl/ && make + cd ./all/gametime/ && make + cd ./all/minput/ && make + cd ./all/nextval/ && make + cd ./all/settings/ && make +else cd ./$(PLATFORM)/wifimanager && make cd ./$(PLATFORM)/libmsettings && make cd ./$(PLATFORM) && make early # eg. other libs @@ -34,14 +50,11 @@ all: cd ./all/settings/ && make cd ./all/ledcontrol/ && make cd ./all/bootlogo/ && make -# BUILDOPTION: don't forget to uncomment this to rebuild cores from -# source, idk if this was left commented by mistake, but I actually -# agree on leaving this commented out by default as they take a long -# while to build and only really need building if someone bothered to -# pull the repo's manually and there are actually updates to any core -# worth including in new NextUI releases. +endif ifdef COMPILE_CORES - $(MAKE) cores + make cores +else + echo "skipping core build" endif cd ./$(PLATFORM) && make @@ -55,9 +68,14 @@ endif cd ./$(PLATFORM)/cores && make $(CORE) clean: +ifneq ($(PLATFORM), desktop) cd ./$(PLATFORM)/wifimanager && make clean - cd ./$(PLATFORM)/libmsettings && make clean cd ./$(PLATFORM)/keymon && make clean + cd ./all/syncsettings/ && make clean + cd ./all/ledcontrol/ && make clean + cd ./all/bootlogo/ && make clean +endif + cd ./$(PLATFORM)/libmsettings && make clean cd ./all/nextui/ && make clean cd ./all/minarch/ && make clean cd ./all/battery/ && make clean @@ -68,9 +86,6 @@ clean: cd ./all/gametimectl/ && make clean cd ./all/gametime/ && make clean cd ./all/minput/ && make clean - cd ./all/syncsettings/ && make clean cd ./all/nextval/ && make clean cd ./all/settings/ && make clean - cd ./all/ledcontrol/ && make clean - cd ./all/bootlogo/ && make clean cd ./$(PLATFORM) && make clean \ No newline at end of file diff --git a/workspace/snapdragonx/notes.txt b/workspace/snapdragonx/notes.txt deleted file mode 100644 index a3f14623a..000000000 --- a/workspace/snapdragonx/notes.txt +++ /dev/null @@ -1,8 +0,0 @@ -This is not a full version of NextUI for macOS. It's a dummy platform to allow using more modern tools to compile and find issues in NextUI's source code without the roundtrip to a device. - -BUILD NEXTUI ------------- -cd workspace/all/nextui -mkdir -p build/macos - -gcc nextui.c -o build/macos/nextui -I. -I../common/ -I../../macos/platform/ -I/opt/homebrew/include -L/opt/homebrew/lib ../common/scaler.c ../common/utils.c ../common/api.c ../../macos/platform/platform.c -fomit-frame-pointer -DPLATFORM=\"macos\" -DUSE_SDL2 -Ofast -std=gnu99 -ldl -flto -lSDL2 -lSDL2_image -lSDL2_ttf -lpthread -lm -lz -fsanitize=address -fno-common -Wno-tautological-constant-out-of-range-compare -Wno-asm-operand-widths && build/macos/nextui diff --git a/workspace/snapdragonx/platform/makefile.copy b/workspace/snapdragonx/platform/makefile.copy deleted file mode 100644 index 118cb925a..000000000 --- a/workspace/snapdragonx/platform/makefile.copy +++ /dev/null @@ -1,2 +0,0 @@ -$(PLATFORM): - # $@ diff --git a/workspace/snapdragonx/platform/makefile.env b/workspace/snapdragonx/platform/makefile.env deleted file mode 100644 index 1e74aa9d7..000000000 --- a/workspace/snapdragonx/platform/makefile.env +++ /dev/null @@ -1,4 +0,0 @@ -# tg5040 -ARCH = -O3 -LIBS = -flto -SDL = SDL2 \ No newline at end of file diff --git a/workspace/snapdragonx/platform/msettings.h b/workspace/snapdragonx/platform/msettings.h deleted file mode 100644 index dd54cd036..000000000 --- a/workspace/snapdragonx/platform/msettings.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef __msettings_h__ -#define __msettings_h__ - -void InitSettings(void); -void QuitSettings(void); - -int GetBrightness(void); -int GetColortemp(void); -int GetVolume(void); - -void SetRawBrightness(int value); // 0-255 -void SetRawVolume(int value); // 0-160 - -void SetBrightness(int value); // 0-10 -void SetColortemp(int value); // 0-10 -void SetVolume(int value); // 0-20 - -int GetJack(void); -void SetJack(int value); // 0-1 - -int GetHDMI(void); -void SetHDMI(int value); // 0-1 - -int GetMute(void); - -#endif // __msettings_h__ diff --git a/workspace/snapdragonx/platform/platform.c b/workspace/snapdragonx/platform/platform.c deleted file mode 100644 index c63adfce5..000000000 --- a/workspace/snapdragonx/platform/platform.c +++ /dev/null @@ -1,550 +0,0 @@ -// macos -#include -#include -// #include -#include -#include - -#include -#include -#include - -#include "msettings.h" - -#include "defines.h" -#include "platform.h" -#include "api.h" -#include "utils.h" - -#include "scaler.h" - - -/////////////////////////////////////// - -// Legacy MinUI settings -typedef struct SettingsV3 { - int version; // future proofing - int brightness; - int headphones; - int speaker; - int mute; - int unused[2]; - int jack; -} SettingsV3; - -// First NextUI settings format -typedef struct SettingsV4 { - int version; // future proofing - int brightness; - int colortemperature; // 0-20 - int headphones; - int speaker; - int mute; - int unused[2]; - int jack; -} SettingsV4; - -// Current NextUI settings format -typedef struct SettingsV5 { - int version; // future proofing - int brightness; - int colortemperature; - int headphones; - int speaker; - int mute; - int unused[2]; // for future use - // NOTE: doesn't really need to be persisted but still needs to be shared - int jack; -} SettingsV5; - -// When incrementing SETTINGS_VERSION, update the Settings typedef and add -// backwards compatibility to InitSettings! -#define SETTINGS_VERSION 5 -typedef SettingsV5 Settings; -static Settings DefaultSettings = { - .version = SETTINGS_VERSION, - .brightness = 2, - .colortemperature = 20, - .headphones = 4, - .speaker = 8, - .mute = 0, - .jack = 0, -}; -static Settings* msettings; - -static char SettingsPath[256]; - -/////////////////////////////////////// - -int peekVersion(const char *filename) { - int version = 0; - FILE *file = fopen(filename, "r"); - if (file) { - fread(&version, sizeof(int), 1, file); - fclose(file); - } - return version; -} - -void InitSettings(void){ - // We are not really using them, but we should be able to debug them - sprintf(SettingsPath, "%s/msettings.bin", SDCARD_PATH "/.userdata"); - msettings = malloc(sizeof(Settings)); - - int version = peekVersion(SettingsPath); - if(version > 0) { - // fopen file pointer - int fd = open(SettingsPath, O_RDONLY); - if(fd) { - if (version == SETTINGS_VERSION) - { - printf("Found settings v5.\n"); - // changes: colortemp 0-40 - // read the rest - read(fd, msettings, sizeof(SettingsV5)); - } - else if(version==4) { - printf("Found settings v4.\n"); - SettingsV4 old; - // read old settings from fd - read(fd, &old, sizeof(SettingsV4)); - // colortemp was 0-20 here - msettings->colortemperature = old.colortemperature * 2; - } - else if(version==3) { - printf("Found settings v3.\n"); - SettingsV3 old; - read(fd, &old, sizeof(SettingsV3)); - // no colortemp setting yet, default value used. - // copy the rest - msettings->brightness = old.brightness; - msettings->headphones = old.headphones; - msettings->speaker = old.speaker; - msettings->mute = old.mute; - msettings->jack = old.jack; - msettings->colortemperature = 20; - } - else { - printf("Found unsupported settings version: %i.\n", version); - // load defaults - memcpy(msettings, &DefaultSettings, sizeof(Settings)); - } - - close(fd); - } - else { - printf("Unable to read settings, using defaults\n"); - // load defaults - memcpy(msettings, &DefaultSettings, sizeof(Settings)); - } - } - else { - printf("No settings found, using defaults\n"); - // load defaults - memcpy(msettings, &DefaultSettings, sizeof(Settings)); - } -} -void QuitSettings(void){ - // dealloc settings - free(msettings); - msettings = NULL; -} - -int GetBrightness(void) { return 0; } -int GetColortemp(void) { return 0; } -int GetVolume(void) { return 0; } - -void SetRawBrightness(int value) {} -void SetRawVolume(int value){} - -void SetBrightness(int value) {} -void SetColortemp(int value) {} -void SetVolume(int value) {} - -int GetJack(void) { return 0; } -void SetJack(int value) {} - -int GetHDMI(void) { return 0; } -void SetHDMI(int value) {} - -int GetMute(void) { return 0; } - -/////////////////////////////// - -static SDL_Joystick *joystick; -void PLAT_initInput(void) { - SDL_InitSubSystem(SDL_INIT_JOYSTICK); - joystick = SDL_JoystickOpen(0); -} -void PLAT_quitInput(void) { - SDL_JoystickClose(joystick); - SDL_QuitSubSystem(SDL_INIT_JOYSTICK); -} - -FILE *PLAT_OpenSettings(const char *filename) -{ - char diskfilename[256]; - snprintf(diskfilename, sizeof(diskfilename), SDCARD_PATH "/.userdata/%s", filename); - - FILE *file = fopen(diskfilename, "r"); - if (file == NULL) - { - return NULL; - - } - return file; -} - -/////////////////////////////// - -static struct VID_Context { - SDL_Window* window; - SDL_Renderer* renderer; - SDL_Texture* texture; - SDL_Surface* buffer; - SDL_Surface* screen; - - GFX_Renderer* blit; // yeesh - - int width; - int height; - int pitch; -} vid; - -static int device_width; -static int device_height; -static int device_pitch; -static int rotate = 0; -SDL_Surface* PLAT_initVideo(void) { - SDL_InitSubSystem(SDL_INIT_VIDEO); - SDL_ShowCursor(0); - // - // LOG_info("Available video drivers:\n"); - // for (int i=0; imode.w) - rotate = 1; - LOG_info("Current display mode: %ix%i (%s)\n", mode.w,mode.h, SDL_GetPixelFormatName(mode.format)); - - int w = FIXED_WIDTH; - int h = FIXED_HEIGHT; - int p = FIXED_PITCH; - vid.window = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w, h, SDL_WINDOW_SHOWN); - vid.renderer = SDL_CreateRenderer(vid.window,-1,SDL_RENDERER_ACCELERATED|SDL_RENDERER_PRESENTVSYNC); - - // SDL_RendererInfo info; - // SDL_GetRendererInfo(vid.renderer, &info); - // LOG_info("Current render driver: %s\n", info.name); - - vid.texture = SDL_CreateTexture(vid.renderer,SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STREAMING, rotate != 0 ? h : w, rotate != 0 ? w : h); - - // SDL_SetTextureScaleMode(vid.texture, SDL_ScaleModeNearest); - - vid.buffer = SDL_CreateRGBSurfaceFrom(NULL, w,h, FIXED_DEPTH, p, RGBA_MASK_565); - vid.screen = SDL_CreateRGBSurface(SDL_SWSURFACE, w,h, FIXED_DEPTH, RGBA_MASK_565); - vid.width = w; - vid.height = h; - vid.pitch = p; - - PWR_disablePowerOff(); - - device_width = w; - device_height = h; - device_pitch = p; - - return vid.screen; -} - -static void clearVideo(void) { - for (int i=0; i<3; i++) { - SDL_RenderClear(vid.renderer); - SDL_FillRect(vid.screen, NULL, 0); - - SDL_LockTexture(vid.texture,NULL,&vid.buffer->pixels,&vid.buffer->pitch); - SDL_FillRect(vid.buffer, NULL, 0); - SDL_UnlockTexture(vid.texture); - SDL_RenderCopy(vid.renderer, vid.texture, NULL, NULL); - - SDL_RenderPresent(vid.renderer); - } -} - -void PLAT_quitVideo(void) { - clearVideo(); - - SDL_FreeSurface(vid.screen); - SDL_FreeSurface(vid.buffer); - SDL_DestroyTexture(vid.texture); - SDL_DestroyRenderer(vid.renderer); - SDL_DestroyWindow(vid.window); - - SDL_Quit(); -} - -void PLAT_clearVideo(SDL_Surface* screen) { - SDL_FillRect(screen, NULL, 0); // TODO: revisit -} -void PLAT_clearAll(void) { - PLAT_clearVideo(vid.screen); // TODO: revist - SDL_RenderClear(vid.renderer); -} - -void PLAT_setVsync(int vsync) { - -} - -static void resizeVideo(int w, int h, int p) { - if (w==vid.width && h==vid.height && p==vid.pitch) return; - - LOG_info("resizeVideo(%i,%i,%i)\n",w,h,p); - - SDL_FreeSurface(vid.buffer); - SDL_DestroyTexture(vid.texture); - // PLAT_clearVideo(vid.screen); - - vid.texture = SDL_CreateTexture(vid.renderer,SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STREAMING, w,h); - // SDL_SetTextureScaleMode(vid.texture, SDL_ScaleModeNearest); - - vid.buffer = SDL_CreateRGBSurfaceFrom(NULL, w,h, FIXED_DEPTH, p, RGBA_MASK_565); - - vid.width = w; - vid.height = h; - vid.pitch = p; -} - -SDL_Surface* PLAT_resizeVideo(int w, int h, int p) { - resizeVideo(w,h,p); - return vid.screen; -} - -void PLAT_setVideoScaleClip(int x, int y, int width, int height) { - -} -void PLAT_setSharpness(int sharpness) { - // buh -} -void PLAT_setEffect(int next_type) { -} - -void PLAT_vsync(int remaining) { - if (remaining>0) SDL_Delay(remaining); -} - -scaler_t PLAT_getScaler(GFX_Renderer* renderer) { - return scale1x1_c16; -} - -void PLAT_blitRenderer(GFX_Renderer* renderer) { - vid.blit = renderer; - SDL_RenderClear(vid.renderer); - resizeVideo(vid.blit->true_w,vid.blit->true_h,vid.blit->src_p); - scale1x1_c16( - renderer->src,renderer->dst, - renderer->true_w,renderer->true_h,renderer->src_p, - vid.screen->w,vid.screen->h,vid.screen->pitch // fixed in this implementation - // renderer->dst_w,renderer->dst_h,renderer->dst_p - ); -} - -void PLAT_flip(SDL_Surface* IGNORED, int ignored) { - if (!vid.blit) { - resizeVideo(device_width,device_height,FIXED_PITCH); // !!!??? - SDL_UpdateTexture(vid.texture,NULL,vid.screen->pixels,vid.screen->pitch); - if (rotate) { - //LOG_info("rotated\n"); - SDL_RenderCopyEx(vid.renderer,vid.texture,NULL,&(SDL_Rect){device_height,0,device_width,device_height},rotate*90,&(SDL_Point){0,0},SDL_FLIP_NONE); - } - else { - //LOG_info("not rotated\n"); - SDL_RenderCopy(vid.renderer, vid.texture, NULL,NULL); - } - SDL_RenderPresent(vid.renderer); - return; - } - - if (!vid.blit) resizeVideo(FIXED_WIDTH,FIXED_HEIGHT,FIXED_PITCH); // !!!??? - - SDL_LockTexture(vid.texture,NULL,&vid.buffer->pixels,&vid.buffer->pitch); - SDL_BlitSurface(vid.screen, NULL, vid.buffer, NULL); - SDL_UnlockTexture(vid.texture); - - SDL_Rect* src_rect = NULL; - SDL_Rect* dst_rect = NULL; - SDL_Rect src_r = {0}; - SDL_Rect dst_r = {0}; - if (vid.blit) { - src_r.x = vid.blit->src_x; - src_r.y = vid.blit->src_y; - src_r.w = vid.blit->src_w; - src_r.h = vid.blit->src_h; - src_rect = &src_r; - - if (vid.blit->aspect==0) { // native (or cropped?) - int w = vid.blit->src_w * vid.blit->scale; - int h = vid.blit->src_h * vid.blit->scale; - int x = (FIXED_WIDTH - w) / 2; - int y = (FIXED_HEIGHT - h) / 2; - - dst_r.x = x; - dst_r.y = y; - dst_r.w = w; - dst_r.h = h; - dst_rect = &dst_r; - } - else if (vid.blit->aspect>0) { // aspect - int h = FIXED_HEIGHT; - int w = h * vid.blit->aspect; - if (w>FIXED_WIDTH) { - double ratio = 1 / vid.blit->aspect; - w = FIXED_WIDTH; - h = w * ratio; - } - int x = (FIXED_WIDTH - w) / 2; - int y = (FIXED_HEIGHT - h) / 2; - - dst_r.x = x; - dst_r.y = y; - dst_r.w = w; - dst_r.h = h; - dst_rect = &dst_r; - } - } - SDL_RenderCopy(vid.renderer, vid.texture, src_rect, dst_rect); - SDL_RenderPresent(vid.renderer); - vid.blit = NULL; -} - -/////////////////////////////// - -// TODO: -#define OVERLAY_WIDTH PILL_SIZE // unscaled -#define OVERLAY_HEIGHT PILL_SIZE // unscaled -#define OVERLAY_BPP 4 -#define OVERLAY_DEPTH 16 -#define OVERLAY_PITCH (OVERLAY_WIDTH * OVERLAY_BPP) // unscaled -#define OVERLAY_RGBA_MASK 0x00ff0000,0x0000ff00,0x000000ff,0xff000000 // ARGB -static struct OVL_Context { - SDL_Surface* overlay; -} ovl; - -SDL_Surface* PLAT_initOverlay(void) { - ovl.overlay = SDL_CreateRGBSurface(SDL_SWSURFACE, SCALE2(OVERLAY_WIDTH,OVERLAY_HEIGHT),OVERLAY_DEPTH,OVERLAY_RGBA_MASK); - return ovl.overlay; -} -void PLAT_quitOverlay(void) { - if (ovl.overlay) SDL_FreeSurface(ovl.overlay); -} -void PLAT_enableOverlay(int enable) { - -} - -/////////////////////////////// - -static int online = 1; -void PLAT_getBatteryStatus(int* is_charging, int* charge) { - PLAT_getBatteryStatusFine(is_charging, charge); -} - -void PLAT_getBatteryStatusFine(int* is_charging, int* charge) -{ - *is_charging = 1; - *charge = 100; -} - -void PLAT_enableBacklight(int enable) { - // buh -} - -void PLAT_powerOff(void) { - SND_quit(); - VIB_quit(); - PWR_quit(); - GFX_quit(); - exit(0); -} - -/////////////////////////////// - -void PLAT_setCPUSpeed(int speed) { - // buh -} - -void PLAT_setRumble(int strength) { - // buh -} - -int PLAT_pickSampleRate(int requested, int max) { - return MIN(requested, max); -} - -char* PLAT_getModel(void) { - return "macOS"; -} - -void PLAT_getOsVersionInfo(char *output_str, size_t max_len) -{ - sprintf(output_str, "%s", "1.2.3"); -} - - -int PLAT_isOnline(void) { - return online; -} - -void PLAT_initLeds(LightSettings *lights) { - -} - -void PLAT_setLedBrightness(LightSettings *led) -{ - -} -void PLAT_setLedEffect(LightSettings *led) -{ - -} -void PLAT_setLedColor(LightSettings *led) -{ - -} - -void PLAT_setLedInbrightness(LightSettings *led) -{ - -} - -void PLAT_setLedEffectCycles(LightSettings *led) -{ - -} - -void PLAT_setLedEffectSpeed(LightSettings *led) -{ - -} - -void *PLAT_cpu_monitor(void *arg) { - -} - -void PLAT_getCPUTemp() { - currentcputemp = 0; - -} diff --git a/workspace/snapdragonx/platform/platform.h b/workspace/snapdragonx/platform/platform.h deleted file mode 100644 index 15dbdec67..000000000 --- a/workspace/snapdragonx/platform/platform.h +++ /dev/null @@ -1,156 +0,0 @@ -// tg5040 - -#ifndef PLATFORM_H -#define PLATFORM_H - -/////////////////////////////// - -#include "sdl.h" - -/////////////////////////////// - -#define BUTTON_UP BUTTON_NA -#define BUTTON_DOWN BUTTON_NA -#define BUTTON_LEFT BUTTON_NA -#define BUTTON_RIGHT BUTTON_NA - -#define BUTTON_SELECT BUTTON_NA -#define BUTTON_START BUTTON_NA - -#define BUTTON_A BUTTON_NA -#define BUTTON_B BUTTON_NA -#define BUTTON_X BUTTON_NA -#define BUTTON_Y BUTTON_NA - -#define BUTTON_L1 BUTTON_NA -#define BUTTON_R1 BUTTON_NA -#define BUTTON_L2 BUTTON_NA -#define BUTTON_R2 BUTTON_NA -#define BUTTON_L3 BUTTON_NA -#define BUTTON_R3 BUTTON_NA - -#define BUTTON_MENU BUTTON_NA -#define BUTTON_MENU_ALT BUTTON_NA -#define BUTTON_POWER BUTTON_NA -#define BUTTON_PLUS BUTTON_NA -#define BUTTON_MINUS BUTTON_NA - -/////////////////////////////// - -// see https://wiki.libsdl.org/SDL2/SDL_Scancode - -#define CODE_UP 82 -#define CODE_DOWN 81 -#define CODE_LEFT 80 -#define CODE_RIGHT 79 - -#define CODE_SELECT 53 -#define CODE_START 40 - -#define CODE_A 22 -#define CODE_B 4 -#define CODE_X 26 -#define CODE_Y 20 - -#define CODE_L1 CODE_NA -#define CODE_R1 CODE_NA -#define CODE_L2 CODE_NA -#define CODE_R2 CODE_NA -#define CODE_L3 CODE_NA -#define CODE_R3 CODE_NA - -#define CODE_MENU 44 -#define CODE_POWER 42 - -#define CODE_PLUS CODE_NA -#define CODE_MINUS CODE_NA - -/////////////////////////////// - // HATS -#define JOY_UP JOY_NA -#define JOY_DOWN JOY_NA -#define JOY_LEFT JOY_NA -#define JOY_RIGHT JOY_NA - -#define JOY_SELECT JOY_NA -#define JOY_START JOY_NA - -// TODO: these ended up swapped in the first public release of stock :sob: -#define JOY_A JOY_NA -#define JOY_B JOY_NA -#define JOY_X JOY_NA -#define JOY_Y JOY_NA - -#define JOY_L1 JOY_NA -#define JOY_R1 JOY_NA -#define JOY_L2 JOY_NA -#define JOY_R2 JOY_NA -#define JOY_L3 JOY_NA -#define JOY_R3 JOY_NA - -#define JOY_MENU JOY_NA -#define JOY_POWER JOY_NA -#define JOY_PLUS JOY_NA -#define JOY_MINUS JOY_NA - -/////////////////////////////// - -#define BTN_RESUME BTN_X -#define BTN_SLEEP BTN_POWER -#define BTN_WAKE BTN_POWER -#define BTN_MOD_VOLUME BTN_NONE -#define BTN_MOD_COLORTEMP BTN_NONE -#define BTN_MOD_BRIGHTNESS BTN_MENU -#define BTN_MOD_PLUS BTN_PLUS -#define BTN_MOD_MINUS BTN_MINUS - -/////////////////////////////// - -// average smallish screen -//#define FIXED_SCALE 2 -//#define FIXED_WIDTH 640 -//#define FIXED_HEIGHT 480 -//#define MAIN_ROW_COUNT 6 -//#define PADDING 10 - -// emulate Brick -//#define FIXED_SCALE 3 -//#define FIXED_WIDTH 1024 -//#define FIXED_HEIGHT 768 -//#define MAIN_ROW_COUNT 7 -//#define PADDING 5 - -// emulate TSP -#define FIXED_SCALE 2 -#define FIXED_WIDTH 1280 -#define FIXED_HEIGHT 720 -#define MAIN_ROW_COUNT 10 -#define PADDING 10 - -#define FIXED_BPP 2 -#define FIXED_DEPTH (FIXED_BPP * 8) -#define FIXED_PITCH (FIXED_WIDTH * FIXED_BPP) -#define FIXED_SIZE (FIXED_PITCH * FIXED_HEIGHT) - -// #define HAS_HDMI 1 -// #define HDMI_WIDTH 1280 -// #define HDMI_HEIGHT 720 -// #define HDMI_PITCH (HDMI_WIDTH * FIXED_BPP) -// #define HDMI_SIZE (HDMI_PITCH * HDMI_HEIGHT) - -/////////////////////////////// - - - -/////////////////////////////// - -#define SDCARD_PATH "/mnt/SDCARD" -#define MUTE_VOLUME_RAW 63 // 0 unintuitively is 100% volume - -#define MAX_LIGHTS 4 - -// this should be set to the devices native screen refresh rate -#define SCREEN_FPS 60.0 -/////////////////////////////// - -#endif diff --git a/workspace/tg5040/keymon/makefile b/workspace/tg5040/keymon/makefile index 0212b6bbc..340117078 100755 --- a/workspace/tg5040/keymon/makefile +++ b/workspace/tg5040/keymon/makefile @@ -8,7 +8,7 @@ TARGET = keymon CC = $(CROSS_COMPILE)gcc CFLAGS = -Os -lmsettings -lpthread -lrt -ldl -Wl,--gc-sections -s -CFLAGS += -I. -I../../all/common -I../platform/ -DPLATFORM=\"$(UNION_PLATFORM)\" +CFLAGS += -I. -I../../all/common -I../platform/ -I$(PREFIX_LOCAL)/include -DPLATFORM=\"$(UNION_PLATFORM)\" all: $(CC) $(TARGET).c -o $(TARGET).elf $(CFLAGS) diff --git a/workspace/tg5040/libmsettings/makefile b/workspace/tg5040/libmsettings/makefile index 990c69f60..f8cac7975 100644 --- a/workspace/tg5040/libmsettings/makefile +++ b/workspace/tg5040/libmsettings/makefile @@ -20,10 +20,13 @@ OPTM=-Ofast build: $(CC) -c -Werror -fpic "$(TARGET).c" $(CFLAGS) -Wl,--no-as-needed $(LDFLAGS) $(CC) -shared -o "lib$(TARGET).so" "$(TARGET).o" $(LDFLAGS) - cp "$(TARGET).h" "$(PREFIX)/include" - cp "lib$(TARGET).so" "$(PREFIX)/lib" + mkdir -p "$(PREFIX_LOCAL)/include" + mkdir -p "$(PREFIX_LOCAL)/lib" + cp "$(TARGET).h" "$(PREFIX_LOCAL)/include" + cp "lib$(TARGET).so" "$(PREFIX_LOCAL)/lib" + clean: rm -f *.o rm -f "lib$(TARGET).so" - rm -f $(PREFIX)/include/$(TARGET).h - rm -f $(PREFIX)/lib/lib$(TARGET).so \ No newline at end of file + rm -f $(PREFIX_LOCAL)/include/$(TARGET).h + rm -f $(PREFIX_LOCAL)/lib/lib$(TARGET).so \ No newline at end of file diff --git a/workspace/tg5040/platform/makefile.env b/workspace/tg5040/platform/makefile.env index c84ea5557..2876afc77 100644 --- a/workspace/tg5040/platform/makefile.env +++ b/workspace/tg5040/platform/makefile.env @@ -4,8 +4,8 @@ CFLAGS = -march=armv8-a+simd -mtune=cortex-a53 -flto SDL = SDL2 GL = GLES # legacy linux paths -CFLAGS += -I$(PREFIX)/include -LDFLAGS = -L$(PREFIX)/lib +CFLAGS += -I$(PREFIX)/include -I$(PREFIX_LOCAL)/include +LDFLAGS = -L$(PREFIX)/lib -I$(PREFIX_LOCAL)/lib # multiarch support CFLAGS += -I$(PREFIX)/include/$(BUILD_ARCH) LDFLAGS += -L$(PREFIX)/lib/$(BUILD_ARCH) @@ -13,5 +13,5 @@ LDFLAGS += -L$(PREFIX)/lib/$(BUILD_ARCH) CFLAGS += $$(pkg-config --cflags sdl2 glesv2) LDFLAGS += $$(pkg-config --libs sdl2 glesv2) # not handled by pkg-config -CFLAGS += -DUSE_$(SDL) -DUSE_$(GL) +CFLAGS += -DUSE_$(SDL) -DUSE_$(GL) -DGL_GLEXT_PROTOTYPES LDFLAGS += -l$(SDL)_image -l$(SDL)_ttf -lpthread -ldl -lm -lz diff --git a/workspace/tg5040/platform/platform.c b/workspace/tg5040/platform/platform.c index e21619dd0..a50b8f59d 100644 --- a/workspace/tg5040/platform/platform.c +++ b/workspace/tg5040/platform/platform.c @@ -22,8 +22,6 @@ #include #include -#include "opengl.h" - #include static int finalScaleFilter=GL_LINEAR;