diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5023aa231..bca5d1997 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -42,6 +42,7 @@ jobs: toolchain: - tg5040 - tg5050 + - my355 steps: - name: Checkout @@ -64,6 +65,7 @@ jobs: toolchain: - tg5040 - tg5050 + - my355 core: ${{ fromJson(needs.core-matrix.outputs.cores) }} steps: - name: Checkout @@ -124,6 +126,18 @@ jobs: env: PLATFORM: tg5050 + - name: Download Cores (my355) + uses: actions/download-artifact@v4.3.0 + with: + path: workspace/my355/cores/output/ + pattern: core-my355-* + merge-multiple: true + + - name: Build (my355) + run: make my355 + env: + PLATFORM: my355 + - name: Special run: make special diff --git a/makefile b/makefile index 2bb42df61..ce5cedb0d 100644 --- a/makefile +++ b/makefile @@ -12,7 +12,7 @@ endif ifeq (,$(PLATFORMS)) #PLATFORMS = miyoomini trimuismart rg35xx rg35xxplus my355 tg5040 zero28 rgb30 m17 gkdpixel my282 magicmini -PLATFORMS = tg5050 tg5040 +PLATFORMS = tg5050 tg5040 my355 endif ########################################################### @@ -51,11 +51,11 @@ deploy: setup $(PLATFORMS) special package adb push ./build/BASE/MinUI.zip /mnt/SDCARD && adb shell reboot all: setup $(PLATFORMS) special package done - + shell: make -f $(TOOLCHAIN_FILE) PLATFORM=$(PLATFORM) -name: +name: @echo $(RELEASE_NAME) build: @@ -78,7 +78,7 @@ endif 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/ @@ -128,7 +128,18 @@ ifeq ($(PLATFORM), tg5050) cp ./workspace/all/minarch/build/$(PLATFORM)/liblzma.* ./build/SYSTEM/$(PLATFORM)/lib/ cp ./workspace/all/minarch/build/$(PLATFORM)/libzstd.* ./build/SYSTEM/$(PLATFORM)/lib/ endif - +ifeq ($(PLATFORM), my355) + cp ./workspace/all/bootlogo/build/$(PLATFORM)/bootlogo.elf ./build/EXTRAS/Tools/$(PLATFORM)/Bootlogo.pak/ + + # lib dependencies + cp ./workspace/all/minarch/build/$(PLATFORM)/libcrypto.* ./build/SYSTEM/$(PLATFORM)/lib/ + cp ./workspace/all/minarch/build/$(PLATFORM)/libsamplerate.* ./build/SYSTEM/$(PLATFORM)/lib/ + # This is a bandaid fix, needs to be cleaned up if/when we expand to other platforms. + cp ./workspace/all/minarch/build/$(PLATFORM)/libzip.* ./build/SYSTEM/$(PLATFORM)/lib/ + cp ./workspace/all/minarch/build/$(PLATFORM)/libbz2.* ./build/SYSTEM/$(PLATFORM)/lib/ + cp ./workspace/all/minarch/build/$(PLATFORM)/liblzma.* ./build/SYSTEM/$(PLATFORM)/lib/ + cp ./workspace/all/minarch/build/$(PLATFORM)/libzstd.* ./build/SYSTEM/$(PLATFORM)/lib/ +endif ifeq ($(PLATFORM), desktop) cores: @@ -145,19 +156,12 @@ cores: # TODO: can't assume every platform will have the same stock cores (platf cp ./workspace/$(PLATFORM)/cores/output/picodrive_libretro.so ./build/SYSTEM/$(PLATFORM)/cores cp ./workspace/$(PLATFORM)/cores/output/snes9x_libretro.so ./build/SYSTEM/$(PLATFORM)/cores cp ./workspace/$(PLATFORM)/cores/output/pcsx_rearmed_libretro.so ./build/SYSTEM/$(PLATFORM)/cores - # extras cp ./workspace/$(PLATFORM)/cores/output/a5200_libretro.so ./build/EXTRAS/Emus/$(PLATFORM)/A5200.pak cp ./workspace/$(PLATFORM)/cores/output/prosystem_libretro.so ./build/EXTRAS/Emus/$(PLATFORM)/A7800.pak cp ./workspace/$(PLATFORM)/cores/output/stella2014_libretro.so ./build/EXTRAS/Emus/$(PLATFORM)/A2600.pak cp ./workspace/$(PLATFORM)/cores/output/handy_libretro.so ./build/EXTRAS/Emus/$(PLATFORM)/LYNX.pak -ifeq ($(PLATFORM), trimuismart) - cp ./workspace/miyoomini/cores/output/fake08_libretro.so ./build/EXTRAS/Emus/$(PLATFORM)/P8.pak -else ifeq ($(PLATFORM), m17) - cp ./workspace/miyoomini/cores/output/fake08_libretro.so ./build/EXTRAS/Emus/$(PLATFORM)/P8.pak -else ifneq ($(PLATFORM),gkdpixel) cp ./workspace/$(PLATFORM)/cores/output/fake08_libretro.so ./build/EXTRAS/Emus/$(PLATFORM)/P8.pak -endif cp ./workspace/$(PLATFORM)/cores/output/mgba_libretro.so ./build/EXTRAS/Emus/$(PLATFORM)/MGBA.pak cp ./workspace/$(PLATFORM)/cores/output/mgba_libretro.so ./build/EXTRAS/Emus/$(PLATFORM)/SGB.pak cp ./workspace/$(PLATFORM)/cores/output/mednafen_pce_fast_libretro.so ./build/EXTRAS/Emus/$(PLATFORM)/PCE.pak @@ -165,10 +169,8 @@ endif cp ./workspace/$(PLATFORM)/cores/output/race_libretro.so ./build/EXTRAS/Emus/$(PLATFORM)/NGP.pak cp ./workspace/$(PLATFORM)/cores/output/race_libretro.so ./build/EXTRAS/Emus/$(PLATFORM)/NGPC.pak cp ./workspace/$(PLATFORM)/cores/output/fbneo_libretro.so ./build/EXTRAS/Emus/$(PLATFORM)/FBN.pak -ifneq ($(PLATFORM),gkdpixel) cp ./workspace/$(PLATFORM)/cores/output/mednafen_supafaust_libretro.so ./build/EXTRAS/Emus/$(PLATFORM)/SUPA.pak cp ./workspace/$(PLATFORM)/cores/output/mednafen_vb_libretro.so ./build/EXTRAS/Emus/$(PLATFORM)/VB.pak -endif cp ./workspace/$(PLATFORM)/cores/output/cap32_libretro.so ./build/EXTRAS/Emus/$(PLATFORM)/CPC.pak cp ./workspace/$(PLATFORM)/cores/output/puae2021_libretro.so ./build/EXTRAS/Emus/$(PLATFORM)/PUAE.pak cp ./workspace/$(PLATFORM)/cores/output/prboom_libretro.so ./build/EXTRAS/Emus/$(PLATFORM)/PRBOOM.pak @@ -182,7 +184,7 @@ endif endif common: build system cores - + clean: rm -rf ./build make clean -f $(TOOLCHAIN_FILE) PLATFORM=$(PLATFORM) COMPILE_CORES=$(COMPILE_CORES) @@ -191,43 +193,43 @@ setup: name # ---------------------------------------------------- # make sure we're running in an input device tty -s || echo "No tty detected" - + # ready fresh build rm -rf ./build mkdir -p ./releases cp -R ./skeleton ./build - + # remove authoring detritus cd ./build && find . -type f -name '.keep' -delete cd ./build && find . -type f -name '*.meta' -delete echo $(BUILD_HASH) > ./workspace/hash.txt - + # copy readmes to workspace so we can use Linux fmt instead of host's mkdir -p ./workspace/readmes cp ./skeleton/BASE/README.txt ./workspace/readmes/BASE-in.txt cp ./skeleton/EXTRAS/README.txt ./workspace/readmes/EXTRAS-in.txt - + done: # say "done" 2>/dev/null || true special: # setup miyoomini/trimui/magicx family .tmp_update in BOOT mv ./build/BOOT/common ./build/BOOT/.tmp_update -# mv ./build/BOOT/miyoo ./build/BASE/ + mv ./build/BOOT/miyoo ./build/BASE/ mv ./build/BOOT/trimui ./build/BASE/ # mv ./build/BOOT/magicx ./build/BASE/ -# cp -R ./build/BOOT/.tmp_update ./build/BASE/miyoo/app/ + cp -R ./build/BOOT/.tmp_update ./build/BASE/miyoo/app/ cp -R ./build/BOOT/.tmp_update ./build/BASE/trimui/app/ # cp -R ./build/BOOT/.tmp_update ./build/BASE/magicx/ # cp -R ./build/BASE/miyoo ./build/BASE/miyoo354 -# cp -R ./build/BASE/miyoo ./build/BASE/miyoo355 -#ifneq (,$(findstring my355, $(PLATFORMS))) -# cp -R ./workspace/my355/init ./build/BASE/miyoo355/app/my355 -# cp -r ./workspace/my355/other/squashfs/output/* ./build/BASE/miyoo355/app/my355/payload/ -#endif + cp -R ./build/BASE/miyoo ./build/BASE/miyoo355 +ifneq (,$(findstring my355, $(PLATFORMS))) + cp -R ./workspace/my355/init ./build/BASE/miyoo355/app/my355 + cp -r ./workspace/my355/other/squashfs/output/* ./build/BASE/miyoo355/app/my355/payload/ +endif tidy: - rm -f releases/$(RELEASE_NAME)-base.zip + rm -f releases/$(RELEASE_NAME)-base.zip rm -f releases/$(RELEASE_NAME)-extras.zip rm -f releases/$(RELEASE_NAME)-all.zip # ---------------------------------------------------- @@ -240,12 +242,12 @@ tidy: package: tidy # ---------------------------------------------------- # zip up build - + # move formatted readmes from workspace to build cp ./workspace/readmes/BASE-out.txt ./build/BASE/README.txt cp ./workspace/readmes/EXTRAS-out.txt ./build/EXTRAS/README.txt rm -rf ./workspace/readmes - + cd ./build/SYSTEM && echo "$(RELEASE_NAME)\n$(BUILD_HASH)" > version.txt ./commits.sh > ./build/SYSTEM/commits.txt cd ./build && find . -type f -name '.DS_Store' -delete @@ -253,7 +255,7 @@ package: tidy mv ./build/SYSTEM ./build/PAYLOAD/.system cp -R ./build/BOOT/.tmp_update ./build/PAYLOAD/ cp -R ./build/EXTRAS/Tools ./build/PAYLOAD/ - + cd ./build/PAYLOAD && zip -r MinUI.zip .system .tmp_update Tools mv ./build/PAYLOAD/MinUI.zip ./build/BASE @@ -269,20 +271,19 @@ package: tidy # Move renamed .pakz files into base folder mkdir -p ./build/BASE mv $(VENDOR_DEST)/* ./build/BASE/ - + # TODO: can I just add everything in BASE to zip? # cd ./build/BASE && zip -r ../../releases/$(RELEASE_NAME)-base.zip Bios Roms Saves miyoo miyoo354 trimui rg35xx rg35xxplus gkdpixel miyoo355 magicx em_ui.sh MinUI.zip README.txt - cd ./build/BASE && zip -r ../../releases/$(RELEASE_NAME)-base.zip Bios Roms Saves Shaders Overlays trimui em_ui.sh MinUI.zip *.pakz README.txt + cd ./build/BASE && zip -r ../../releases/$(RELEASE_NAME)-base.zip Bios Roms Saves Shaders Overlays trimui miyoo miyoo355 em_ui.sh MinUI.zip *.pakz README.txt cd ./build/EXTRAS && zip -r ../../releases/$(RELEASE_NAME)-extras.zip Bios Emus Roms Saves Shaders Overlays Tools README.txt echo "$(RELEASE_VERSION)" > ./build/latest.txt - # compound zip (brew install libzip needed) + # compound zip (brew install libzip needed) cd ./releases && zipmerge $(RELEASE_NAME)-all.zip $(RELEASE_NAME)-base.zip && zipmerge $(RELEASE_NAME)-all.zip $(RELEASE_NAME)-extras.zip - + ########################################################### .DEFAULT: # ---------------------------------------------------- # $@ @echo "$(PLATFORMS)" | grep -q "\b$@\b" && (make common PLATFORM=$@) || (exit 1) - diff --git a/skeleton/BOOT/common/updater b/skeleton/BOOT/common/updater index b60bf4233..376c4747e 100755 --- a/skeleton/BOOT/common/updater +++ b/skeleton/BOOT/common/updater @@ -36,7 +36,7 @@ if [ -z "$PLATFORM" ] && [ -f /usr/trimui/bin/runtrimui.sh ]; then PLATFORM="tg5040" fi -/mnt/SDCARD/.tmp_update/$PLATFORM.sh # &> /mnt/SDCARD/boot.txt +/mnt/SDCARD/.tmp_update/$PLATFORM.sh &> /mnt/SDCARD/boot.txt # force shutdown so nothing can modify the SD card echo s > /proc/sysrq-trigger diff --git a/skeleton/BOOT/miyoo/app/MainUI b/skeleton/BOOT/miyoo/app/MainUI new file mode 100644 index 000000000..90b8bec26 --- /dev/null +++ b/skeleton/BOOT/miyoo/app/MainUI @@ -0,0 +1,16 @@ +#!/bin/sh + +cd $(dirname "$0") + +INFO=`cat /proc/cpuinfo 2> /dev/null` +case $INFO in +*"0xd05"*) + ./my355.sh + ;; +*"sun8i"*) + ./my282.sh + ;; +*"SStar"*) + ./miyoomini.sh + ;; +esac \ No newline at end of file diff --git a/skeleton/BOOT/miyoo/app/keymon b/skeleton/BOOT/miyoo/app/keymon new file mode 100644 index 000000000..c52d3c26b --- /dev/null +++ b/skeleton/BOOT/miyoo/app/keymon @@ -0,0 +1,3 @@ +#!/bin/sh + +exit 0 diff --git a/skeleton/BOOT/miyoo/app/my355.sh b/skeleton/BOOT/miyoo/app/my355.sh new file mode 100644 index 000000000..81a33e20f --- /dev/null +++ b/skeleton/BOOT/miyoo/app/my355.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +cd $(dirname "$0") + +SDCARD_PATH=/mnt/SDCARD +MIYOO_DIR=miyoo355 + +if [ ! -f /usr/miyoo/bin/runmiyoo-original.sh ]; then + if [ -d $SDCARD_PATH/.tmp_update/ ]; then + rm -rf $SDCARD_PATH/.tmp_update/ + fi + my355/init.sh +fi + +export PATH=/usr/miyoo/bin:/usr/miyoo/sbin:/usr/bin:/usr/sbin:/bin:/sbin +export LD_LIBRARY_PATH=/usr/miyoo/lib:/usr/lib:/lib + + +# .tmp_update/updater does the actual installation (and later, updating) +cp -rf .tmp_update $SDCARD_PATH/ +rm -rf "$SDCARD_PATH/$MIYOO_DIR" +sync +$SDCARD_PATH/.tmp_update/updater + +# under no circumstances should stock be allowed to touch this card +poweroff diff --git a/skeleton/EXTRAS/Emus/my355/FBN.pak/default.cfg b/skeleton/EXTRAS/Emus/my355/FBN.pak/default.cfg new file mode 100755 index 000000000..cff2093e2 --- /dev/null +++ b/skeleton/EXTRAS/Emus/my355/FBN.pak/default.cfg @@ -0,0 +1,15 @@ +-fbneo-vertical-mode = disabled +bind Up = UP +bind Down = DOWN +bind Left = LEFT +bind Right = RIGHT +bind Select = SELECT +bind Start = START +bind X Button = X +bind Y Button = Y +bind B Button = B +bind A Button = A +bind L1 Button = L1 +bind L2 Button = L2 +bind R1 Button = R1 +bind R2 Button = R2 \ No newline at end of file diff --git a/skeleton/EXTRAS/Emus/my355/FBN.pak/launch.sh b/skeleton/EXTRAS/Emus/my355/FBN.pak/launch.sh new file mode 100755 index 000000000..4022ab817 --- /dev/null +++ b/skeleton/EXTRAS/Emus/my355/FBN.pak/launch.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +EMU_EXE=fbneo +CORES_PATH=$(dirname "$0") +############################### + +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/EXTRAS/Emus/my355/GG.pak/default.cfg b/skeleton/EXTRAS/Emus/my355/GG.pak/default.cfg new file mode 100644 index 000000000..44ce34743 --- /dev/null +++ b/skeleton/EXTRAS/Emus/my355/GG.pak/default.cfg @@ -0,0 +1,18 @@ +-picodrive_smstype = Game Gear +-picodrive_smsmapper = Auto +-picodrive_sound_rate = 44100 +-picodrive_ramcart = disabled +-picodrive_dacnoise = disabled +-picodrive_input1 = 3 button pad +-picodrive_input2 = 3 button pad +-picodrive_fm_filter = off +-picodrive_audio_filter = disabled +-picodrive_overclk68k = disabled + +bind Up = UP +bind Down = DOWN +bind Left = LEFT +bind Right = RIGHT +bind Button 1 = B +bind Button 2 = A +bind Pause = START \ No newline at end of file diff --git a/skeleton/EXTRAS/Emus/my355/GG.pak/launch.sh b/skeleton/EXTRAS/Emus/my355/GG.pak/launch.sh new file mode 100644 index 000000000..bfb54a087 --- /dev/null +++ b/skeleton/EXTRAS/Emus/my355/GG.pak/launch.sh @@ -0,0 +1,13 @@ +#!/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" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" > "$LOGS_PATH/$EMU_TAG.txt" 2>&1 diff --git a/skeleton/EXTRAS/Emus/my355/MGBA.pak/default.cfg b/skeleton/EXTRAS/Emus/my355/MGBA.pak/default.cfg new file mode 100644 index 000000000..266d90c20 --- /dev/null +++ b/skeleton/EXTRAS/Emus/my355/MGBA.pak/default.cfg @@ -0,0 +1,18 @@ +mgba_skip_bios = ON + +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 +bind L Turbo = NONE:L2 +bind R Turbo = NONE:R2 +bind More Sun = NONE:L3 +bind Less Sun = NONE:R3 \ No newline at end of file diff --git a/skeleton/EXTRAS/Emus/my355/MGBA.pak/launch.sh b/skeleton/EXTRAS/Emus/my355/MGBA.pak/launch.sh new file mode 100644 index 000000000..76a50ce0a --- /dev/null +++ b/skeleton/EXTRAS/Emus/my355/MGBA.pak/launch.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +EMU_EXE=mgba +CORES_PATH=$(dirname "$0") + +############################### + +EMU_TAG=$(basename "$(dirname "$0")" .pak) +ROM="$1" +mkdir -p "$BIOS_PATH/$EMU_TAG" +mkdir -p "$SAVES_PATH/$EMU_TAG" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" > "$LOGS_PATH/$EMU_TAG.txt" 2>&1 diff --git a/skeleton/EXTRAS/Emus/my355/NGP.pak/default.cfg b/skeleton/EXTRAS/Emus/my355/NGP.pak/default.cfg new file mode 100644 index 000000000..33f5a6b95 --- /dev/null +++ b/skeleton/EXTRAS/Emus/my355/NGP.pak/default.cfg @@ -0,0 +1,9 @@ +race_dark_filter_level = 50 + +bind Up = UP +bind Down = DOWN +bind Left = LEFT +bind Right = RIGHT +bind A Button = B +bind B Button = A +bind Option = START \ No newline at end of file diff --git a/skeleton/EXTRAS/Emus/my355/NGP.pak/launch.sh b/skeleton/EXTRAS/Emus/my355/NGP.pak/launch.sh new file mode 100644 index 000000000..2444d45f3 --- /dev/null +++ b/skeleton/EXTRAS/Emus/my355/NGP.pak/launch.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +EMU_EXE=race +CORES_PATH=$(dirname "$0") + +############################### + +EMU_TAG=$(basename "$(dirname "$0")" .pak) +ROM="$1" +mkdir -p "$BIOS_PATH/$EMU_TAG" +mkdir -p "$SAVES_PATH/$EMU_TAG" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" > "$LOGS_PATH/$EMU_TAG.txt" 2>&1 diff --git a/skeleton/EXTRAS/Emus/my355/NGPC.pak/default.cfg b/skeleton/EXTRAS/Emus/my355/NGPC.pak/default.cfg new file mode 100644 index 000000000..7d05719ba --- /dev/null +++ b/skeleton/EXTRAS/Emus/my355/NGPC.pak/default.cfg @@ -0,0 +1,7 @@ +bind Up = UP +bind Down = DOWN +bind Left = LEFT +bind Right = RIGHT +bind A Button = B +bind B Button = A +bind Option = START \ No newline at end of file diff --git a/skeleton/EXTRAS/Emus/my355/NGPC.pak/launch.sh b/skeleton/EXTRAS/Emus/my355/NGPC.pak/launch.sh new file mode 100644 index 000000000..2444d45f3 --- /dev/null +++ b/skeleton/EXTRAS/Emus/my355/NGPC.pak/launch.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +EMU_EXE=race +CORES_PATH=$(dirname "$0") + +############################### + +EMU_TAG=$(basename "$(dirname "$0")" .pak) +ROM="$1" +mkdir -p "$BIOS_PATH/$EMU_TAG" +mkdir -p "$SAVES_PATH/$EMU_TAG" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" > "$LOGS_PATH/$EMU_TAG.txt" 2>&1 diff --git a/skeleton/EXTRAS/Emus/my355/P8.pak/default.cfg b/skeleton/EXTRAS/Emus/my355/P8.pak/default.cfg new file mode 100644 index 000000000..73611d3f3 --- /dev/null +++ b/skeleton/EXTRAS/Emus/my355/P8.pak/default.cfg @@ -0,0 +1,7 @@ +bind Up = UP +bind Down = DOWN +bind Left = LEFT +bind Right = RIGHT +bind A Button = A +bind B Button = B +bind Start = START \ No newline at end of file diff --git a/skeleton/EXTRAS/Emus/my355/P8.pak/launch.sh b/skeleton/EXTRAS/Emus/my355/P8.pak/launch.sh new file mode 100644 index 000000000..dcb674e31 --- /dev/null +++ b/skeleton/EXTRAS/Emus/my355/P8.pak/launch.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +EMU_EXE=fake08 +CORES_PATH=$(dirname "$0") + +############################### + +EMU_TAG=$(basename "$(dirname "$0")" .pak) +ROM="$1" +mkdir -p "$BIOS_PATH/$EMU_TAG" +mkdir -p "$SAVES_PATH/$EMU_TAG" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" > "$LOGS_PATH/$EMU_TAG.txt" 2>&1 diff --git a/skeleton/EXTRAS/Emus/my355/PCE.pak/default.cfg b/skeleton/EXTRAS/Emus/my355/PCE.pak/default.cfg new file mode 100644 index 000000000..671219086 --- /dev/null +++ b/skeleton/EXTRAS/Emus/my355/PCE.pak/default.cfg @@ -0,0 +1,15 @@ +-pce_fast_turbo_toggle_hotkey = disabled + +bind Up = UP +bind Down = DOWN +bind Left = LEFT +bind Right = RIGHT +bind Select = SELECT +bind Run = START +bind I = A +bind II = B +bind III = Y +bind IV = X +bind V = L1 +bind VI = R1 +bind Mode = L2 \ No newline at end of file diff --git a/skeleton/EXTRAS/Emus/my355/PCE.pak/launch.sh b/skeleton/EXTRAS/Emus/my355/PCE.pak/launch.sh new file mode 100644 index 000000000..4f0d356b6 --- /dev/null +++ b/skeleton/EXTRAS/Emus/my355/PCE.pak/launch.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +EMU_EXE=mednafen_pce_fast +CORES_PATH=$(dirname "$0") + +############################### + +EMU_TAG=$(basename "$(dirname "$0")" .pak) +ROM="$1" +mkdir -p "$BIOS_PATH/$EMU_TAG" +mkdir -p "$SAVES_PATH/$EMU_TAG" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" > "$LOGS_PATH/$EMU_TAG.txt" 2>&1 diff --git a/skeleton/EXTRAS/Emus/my355/PKM.pak/default.cfg b/skeleton/EXTRAS/Emus/my355/PKM.pak/default.cfg new file mode 100644 index 000000000..f6d20d9bb --- /dev/null +++ b/skeleton/EXTRAS/Emus/my355/PKM.pak/default.cfg @@ -0,0 +1,17 @@ +minarch_screen_scaling = Native + +pokemini_video_scale = 3x +-pokemini_60hz_mode = enabled +pokemini_palette = Old +pokemini_piezofilter = disabled +pokemini_lowpass_filter = enabled + +bind Up = UP +bind Down = DOWN +bind Left = LEFT +bind Right = RIGHT +bind A Button = A +bind B Button = B +bind C Button = R1 +bind Shake = L1 +bind Power = SELECT diff --git a/skeleton/EXTRAS/Emus/my355/PKM.pak/launch.sh b/skeleton/EXTRAS/Emus/my355/PKM.pak/launch.sh new file mode 100644 index 000000000..fe0149af8 --- /dev/null +++ b/skeleton/EXTRAS/Emus/my355/PKM.pak/launch.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +EMU_EXE=pokemini +CORES_PATH=$(dirname "$0") + +############################### + +EMU_TAG=$(basename "$(dirname "$0")" .pak) +ROM="$1" +mkdir -p "$BIOS_PATH/$EMU_TAG" +mkdir -p "$SAVES_PATH/$EMU_TAG" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" > "$LOGS_PATH/$EMU_TAG.txt" 2>&1 diff --git a/skeleton/EXTRAS/Emus/my355/SGB.pak/default.cfg b/skeleton/EXTRAS/Emus/my355/SGB.pak/default.cfg new file mode 100644 index 000000000..78fdedb28 --- /dev/null +++ b/skeleton/EXTRAS/Emus/my355/SGB.pak/default.cfg @@ -0,0 +1,24 @@ +-mgba_gb_model = Super Game Boy +mgba_skip_bios = ON +-mgba_gb_colors_preset = 2 +-mgba_force_gbp = OFF +-mgba_color_correction = OFF +-mgba_interframe_blending = OFF +mgba_sgb_borders = ON + +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 +bind L Turbo = NONE:L2 +bind R Turbo = NONE:R2 +bind More Sun = NONE:L3 +bind Less Sun = NONE:R3 \ No newline at end of file diff --git a/skeleton/EXTRAS/Emus/my355/SGB.pak/launch.sh b/skeleton/EXTRAS/Emus/my355/SGB.pak/launch.sh new file mode 100644 index 000000000..76a50ce0a --- /dev/null +++ b/skeleton/EXTRAS/Emus/my355/SGB.pak/launch.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +EMU_EXE=mgba +CORES_PATH=$(dirname "$0") + +############################### + +EMU_TAG=$(basename "$(dirname "$0")" .pak) +ROM="$1" +mkdir -p "$BIOS_PATH/$EMU_TAG" +mkdir -p "$SAVES_PATH/$EMU_TAG" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" > "$LOGS_PATH/$EMU_TAG.txt" 2>&1 diff --git a/skeleton/EXTRAS/Emus/my355/SMS.pak/default.cfg b/skeleton/EXTRAS/Emus/my355/SMS.pak/default.cfg new file mode 100644 index 000000000..0d2df362d --- /dev/null +++ b/skeleton/EXTRAS/Emus/my355/SMS.pak/default.cfg @@ -0,0 +1,19 @@ +-picodrive_smstype = Master System +picodrive_smsmapper = Auto +-picodrive_ggghost = off +-picodrive_sound_rate = 44100 +-picodrive_ramcart = disabled +-picodrive_dacnoise = disabled +-picodrive_input1 = 3 button pad +-picodrive_input2 = 3 button pad +-picodrive_fm_filter = off +-picodrive_audio_filter = disabled +-picodrive_overclk68k = disabled + +bind Up = UP +bind Down = DOWN +bind Left = LEFT +bind Right = RIGHT +bind Button 1 = B +bind Button 2 = A +bind Pause = START diff --git a/skeleton/EXTRAS/Emus/my355/SMS.pak/launch.sh b/skeleton/EXTRAS/Emus/my355/SMS.pak/launch.sh new file mode 100644 index 000000000..bfb54a087 --- /dev/null +++ b/skeleton/EXTRAS/Emus/my355/SMS.pak/launch.sh @@ -0,0 +1,13 @@ +#!/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" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" > "$LOGS_PATH/$EMU_TAG.txt" 2>&1 diff --git a/skeleton/EXTRAS/Emus/my355/SUPA.pak/default.cfg b/skeleton/EXTRAS/Emus/my355/SUPA.pak/default.cfg new file mode 100644 index 000000000..07fcd8d65 --- /dev/null +++ b/skeleton/EXTRAS/Emus/my355/SUPA.pak/default.cfg @@ -0,0 +1,15 @@ +-supafaust_pixel_format = rgb565 +-supafaust_thread_affinity_emu = 0x0 + +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/EXTRAS/Emus/my355/SUPA.pak/launch.sh b/skeleton/EXTRAS/Emus/my355/SUPA.pak/launch.sh new file mode 100644 index 000000000..55f54bd9f --- /dev/null +++ b/skeleton/EXTRAS/Emus/my355/SUPA.pak/launch.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +EMU_EXE=mednafen_supafaust +CORES_PATH=$(dirname "$0") + +############################### + +EMU_TAG=$(basename "$(dirname "$0")" .pak) +ROM="$1" +mkdir -p "$BIOS_PATH/$EMU_TAG" +mkdir -p "$SAVES_PATH/$EMU_TAG" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" > "$LOGS_PATH/$EMU_TAG.txt" 2>&1 diff --git a/skeleton/EXTRAS/Emus/my355/VB.pak/default.cfg b/skeleton/EXTRAS/Emus/my355/VB.pak/default.cfg new file mode 100644 index 000000000..a83095a2b --- /dev/null +++ b/skeleton/EXTRAS/Emus/my355/VB.pak/default.cfg @@ -0,0 +1,20 @@ +minarch_cpu_speed = Performance + +-vb_3dmode = anaglyph +-vb_right_analog_to_digital = disabled + +bind L. Up = UP +bind L. Down = DOWN +bind L. Left = LEFT +bind L. Right = RIGHT +bind Select = SELECT +bind Start = START +bind A = A +bind B = B +bind L Button = L1 +bind R Button = R1 +bind Low Battery = NONE:X +bind R. Up = NONE:L2 +bind R. Down = NONE:L3 +bind R. Left = NONE:R2 +bind R. Right = NONE:R3 diff --git a/skeleton/EXTRAS/Emus/my355/VB.pak/launch.sh b/skeleton/EXTRAS/Emus/my355/VB.pak/launch.sh new file mode 100644 index 000000000..ae427aec8 --- /dev/null +++ b/skeleton/EXTRAS/Emus/my355/VB.pak/launch.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +EMU_EXE=mednafen_vb +CORES_PATH=$(dirname "$0") + +############################### + +EMU_TAG=$(basename "$(dirname "$0")" .pak) +ROM="$1" +mkdir -p "$BIOS_PATH/$EMU_TAG" +mkdir -p "$SAVES_PATH/$EMU_TAG" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" > "$LOGS_PATH/$EMU_TAG.txt" 2>&1 diff --git a/skeleton/EXTRAS/Tools/my355/Battery.pak/launch.sh b/skeleton/EXTRAS/Tools/my355/Battery.pak/launch.sh new file mode 100644 index 000000000..c7cd4fcde --- /dev/null +++ b/skeleton/EXTRAS/Tools/my355/Battery.pak/launch.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +cd $(dirname "$0") +./battery.elf # &> ./log.txt diff --git a/skeleton/EXTRAS/Tools/my355/Bootlogo.pak/apply.sh b/skeleton/EXTRAS/Tools/my355/Bootlogo.pak/apply.sh new file mode 100644 index 000000000..9ebddd8fa --- /dev/null +++ b/skeleton/EXTRAS/Tools/my355/Bootlogo.pak/apply.sh @@ -0,0 +1,79 @@ +#!/bin/sh +set -x + +export PATH=/tmp/bin:$PATH +export LD_LIBRARY_PATH=/tmp/lib:$LD_LIBRARY_PATH + +DIR="$(cd "$(dirname "$0")" && pwd)" +LAST_CALL_TIME=0 +hide() { + killall show.elf || true +} +show() { + CURRENT_TIME=$(date +%s) + if [ $((CURRENT_TIME - LAST_CALL_TIME)) -lt 2 ]; then + DELAY=$((2 - (CURRENT_TIME - LAST_CALL_TIME))) + echo "delay for $DELAY seconds" + sleep $DELAY + fi + + hide + show.elf $DIR/res/$1 300 & + LAST_CALL_TIME=$(date +%s) +} + +show "prep-env.png" +echo "preparing environment" +cd $(dirname "$0") +cp -r payload/* /tmp +cd /tmp + +show "extract-img.png" +echo "extracting boot.img" +dd if=/dev/mtd2ro of=boot.img bs=131072 + +show "unpack-img.png" +echo "unpacking boot.img" +mkdir -p bootimg +unpackbootimg -i boot.img -o bootimg + +show "unpack-res.png" +echo "unpacking resources" +mkdir -p bootres +cp bootimg/boot.img-second bootres/ +cd bootres +rsce_tool -u boot.img-second + +show "replace-logo.png" +echo "replacing logo" +cp -f ../logo.bmp ./ +cp -f ../logo.bmp ./logo_kernel.bmp + +show "pack-res.png" +echo "packing updated resources" +for file in *; do + [ "$(basename "$file")" != "boot.img-second" ] && set -- "$@" -p "$file" +done +rsce_tool "$@" + +show "pack-img.png" +echo "packing updated boot.img" +cp -f boot-second ../bootimg +cd ../ +rm boot.img +mkbootimg --kernel bootimg/boot.img-kernel --second bootimg/boot-second --base 0x10000000 --kernel_offset 0x00008000 --ramdisk_offset 0xf0000000 --second_offset 0x00f00000 --pagesize 2048 --hashtype sha1 -o boot.img + +show "flash-img.png" +echo "flashing updated boot.img" +flashcp boot.img /dev/mtd2 && sync + +show "reboot.png" +echo "done, rebooting" + +sleep 2 + +# self-destruct +mv $DIR $DIR.disabled +reboot + +exit \ No newline at end of file diff --git a/skeleton/EXTRAS/Tools/my355/Bootlogo.pak/launch.sh b/skeleton/EXTRAS/Tools/my355/Bootlogo.pak/launch.sh new file mode 100644 index 000000000..7f6676f36 --- /dev/null +++ b/skeleton/EXTRAS/Tools/my355/Bootlogo.pak/launch.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +cd $(dirname "$0") +./apply.sh > ./log.txt 2>&1 \ No newline at end of file diff --git a/skeleton/EXTRAS/Tools/my355/Clock.pak/launch.sh b/skeleton/EXTRAS/Tools/my355/Clock.pak/launch.sh new file mode 100644 index 000000000..7eba99d00 --- /dev/null +++ b/skeleton/EXTRAS/Tools/my355/Clock.pak/launch.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +cd $(dirname "$0") +./clock.elf diff --git a/skeleton/EXTRAS/Tools/my355/Files.pak/launch.sh b/skeleton/EXTRAS/Tools/my355/Files.pak/launch.sh new file mode 100644 index 000000000..30db9507a --- /dev/null +++ b/skeleton/EXTRAS/Tools/my355/Files.pak/launch.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +cd $(dirname "$0") + +HOME="$SDCARD_PATH" +CFG="my355.cfg" + + +./NextCommander --config $CFG > launch.log \ No newline at end of file diff --git a/skeleton/EXTRAS/Tools/my355/Files.pak/my355.cfg b/skeleton/EXTRAS/Tools/my355/Files.pak/my355.cfg new file mode 100644 index 000000000..97aa5ede2 --- /dev/null +++ b/skeleton/EXTRAS/Tools/my355/Files.pak/my355.cfg @@ -0,0 +1,6 @@ +disp_width=640 +disp_height=480 +disp_autoscale=1 +disp_autoscale_dpi=1 +disp_ppu_x=1 +disp_ppu_y=1 \ No newline at end of file diff --git a/skeleton/EXTRAS/Tools/my355/Game Tracker.pak/launch.sh b/skeleton/EXTRAS/Tools/my355/Game Tracker.pak/launch.sh new file mode 100644 index 000000000..86e09ee15 --- /dev/null +++ b/skeleton/EXTRAS/Tools/my355/Game Tracker.pak/launch.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +cd "$(dirname "$0")" +./gametime.elf # &> ./log.txt diff --git a/skeleton/EXTRAS/Tools/my355/Input.pak/launch.sh b/skeleton/EXTRAS/Tools/my355/Input.pak/launch.sh new file mode 100644 index 000000000..ca0aefe28 --- /dev/null +++ b/skeleton/EXTRAS/Tools/my355/Input.pak/launch.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +cd $(dirname "$0") +./minput.elf diff --git a/skeleton/EXTRAS/Tools/my355/Remove Loading.pak/launch.sh b/skeleton/EXTRAS/Tools/my355/Remove Loading.pak/launch.sh new file mode 100644 index 000000000..fbbe1d12e --- /dev/null +++ b/skeleton/EXTRAS/Tools/my355/Remove Loading.pak/launch.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +DIR="$(dirname "$0")" +cd "$DIR" + +sed -i '/^\/usr\/sbin\/pic2fb \/etc\/splash.png/d' /etc/init.d/runtrimui +show.elf "$DIR/$DEVICE/done.png" 2 + +mv "$DIR" "$DIR.disabled" \ No newline at end of file diff --git a/skeleton/EXTRAS/Tools/my355/Settings.pak/launch.sh b/skeleton/EXTRAS/Tools/my355/Settings.pak/launch.sh new file mode 100644 index 000000000..006467eae --- /dev/null +++ b/skeleton/EXTRAS/Tools/my355/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/my355/bin/shutdown b/skeleton/SYSTEM/my355/bin/shutdown new file mode 100755 index 000000000..a5a5d03a9 --- /dev/null +++ b/skeleton/SYSTEM/my355/bin/shutdown @@ -0,0 +1,17 @@ +#!/bin/sh + +if [ -n "$DATETIME_PATH" ]; then + echo `date +'%F %T'` > "$DATETIME_PATH" + sync +fi + +cat /dev/zero > /dev/fb0 +poweroff + +while :; do + sleep 5 +done + +# echo s > /proc/sysrq-trigger +# echo u > /proc/sysrq-trigger +# echo o > /proc/sysrq-trigger diff --git a/skeleton/SYSTEM/my355/bin/suspend b/skeleton/SYSTEM/my355/bin/suspend new file mode 100755 index 000000000..6dd9a2bd0 --- /dev/null +++ b/skeleton/SYSTEM/my355/bin/suspend @@ -0,0 +1,60 @@ +#!/bin/sh +set -euo pipefail +exec 0<&- + +log() { + >&2 echo "$1" + + # DEBUGGING + # echo "$1" >> /mnt/SDCARD/debug.log +} + +fix_sleep_sound_bug() { + # turn it off and on againt + val=$(amixer cget numid=2 | awk -F'values=' '/: values/{print $2}') + amixer cset numid=2 0 + amixer cset numid=2 $val +} + +before() { + log "Preparing for suspend..." + + # Probably not necessary and dangerous actually + # log "Turning off input" + # echo 0 > /sys/module/gpio_keys_polled/parameters/button_enable + + # TODO bluetooth + # TODO wifi + + touch /tmp/system_suspend +} + +after() { + # log "Turning on input" + # echo 1 > /sys/module/gpio_keys_polled/parameters/button_enable + + log "Restoring brightness" + # TODO save and restore backlight settings + echo 100 > /sys/class/leds/work/brightness + + log "Restoring sound" + fix_sleep_sound_bug + + # TODO bluetooth + # TODO wifi + + rm /tmp/system_suspend + + log "Resumed from suspend." +} + +before + +log "Suspending..." +sync +echo deep > /sys/power/mem_sleep +echo mem > /sys/power/state +log "Resuming..." + +# Resume services in background to reduce UI latency +after & diff --git a/skeleton/SYSTEM/my355/cores/.keep b/skeleton/SYSTEM/my355/cores/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/skeleton/SYSTEM/my355/dat/.keep b/skeleton/SYSTEM/my355/dat/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/skeleton/SYSTEM/my355/etc/bluetooth/bt_init.sh b/skeleton/SYSTEM/my355/etc/bluetooth/bt_init.sh new file mode 100755 index 000000000..885a775dd --- /dev/null +++ b/skeleton/SYSTEM/my355/etc/bluetooth/bt_init.sh @@ -0,0 +1,130 @@ +#!/bin/sh +# Taken from allwinner/btmanager/config/xradio_bt_init.sh for NextUI +bt_hciattach="hciattach" + +start_hci_attach() +{ + h=`ps | grep "$bt_hciattach" | grep -v grep` + [ -n "$h" ] && { + killall "$bt_hciattach" + } + + #xradio init + "$bt_hciattach" -n ttyS1 xradio >/dev/null 2>&1 & + + wait_hci0_count=0 + while true + do + [ -d /sys/class/bluetooth/hci0 ] && break + usleep 100000 + let wait_hci0_count++ + [ $wait_hci0_count -eq 70 ] && { + echo "bring up hci0 failed" + exit 1 + } + done +} + +start() { + rfkill.elf unblock bluetooth + + if [ -d "/sys/class/bluetooth/hci0" ];then + echo "Bluetooth init has been completed!!" + else + start_hci_attach + fi + + d=`ps | grep bluetoothd | grep -v grep` + [ -z "$d" ] && { + /etc/bluetooth/bluetoothd start + sleep 1 + } + + a=`ps | grep bluealsa | grep -v grep` + [ -z "$a" ] && { + # bluealsa -p a2dp-source --keep-alive=-1 & + bluealsa -p a2dp-source & + sleep 1 + } + + b=`ps | grep bt_daemon | grep -v grep` + [ -z "$b" ] && { + bt_daemon -s & + # sleep 1 + } + +} + +ble_start() { + rfkill.elf unblock bluetooth + + if [ -d "/sys/class/bluetooth/hci0" ];then + echo "Bluetooth init has been completed!!" + else + start_hci_attach + fi + + hci_is_up=`hciconfig hci0 | grep RUNNING` + [ -z "$hci_is_up" ] && { + hciconfig hci0 up + } + + MAC_STR=`hciconfig | grep "BD Address" | awk '{print $3}'` + LE_MAC=${MAC_STR/2/C} + OLD_LE_MAC_T=`cat /sys/kernel/debug/bluetooth/hci0/random_address` + OLD_LE_MAC=$(echo $OLD_LE_MAC_T | tr [a-z] [A-Z]) + if [ -n "$LE_MAC" ];then + if [ "$LE_MAC" != "$OLD_LE_MAC" ];then + hciconfig hci0 lerandaddr $LE_MAC + else + echo "the ble random_address has been set." + fi + fi +} + +stop() { + + b=`ps | grep bt_daemon | grep -v grep` + [ -n "$b" ] && { + killall bt_daemon + #sleep 1 + } + + a=`ps | grep bluealsa | grep -v grep` + [ -n "$a" ] && { + killall bluealsa + sleep 1 + } + + d=`ps | grep bluetoothd | grep -v grep` + [ -n "$d" ] && { + killall bluetoothd + sleep 1 + } + + h=`ps | grep "$bt_hciattach" | grep -v grep` + [ -n "$h" ] && { + killall "$bt_hciattach" + sleep 1 + } + + rfkill.elf block bluetooth + #echo 0 > /sys/class/rfkill/rfkill0/state; + sleep 1 + echo "stop bluetoothd and hciattach" +} + +case "$1" in + start|"") + start + ;; + stop) + stop + ;; + ble_start) + ble_start + ;; + *) + echo "Usage: $0 {start|stop}" + exit 1 +esac \ No newline at end of file diff --git a/skeleton/SYSTEM/my355/etc/wifi/wifi_init.sh b/skeleton/SYSTEM/my355/etc/wifi/wifi_init.sh new file mode 100755 index 000000000..843d7c6e4 --- /dev/null +++ b/skeleton/SYSTEM/my355/etc/wifi/wifi_init.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +start() { + rfkill.elf unblock wifi + + /etc/init.d/wpa_supplicant start + + wifi_daemon -s & +} + +stop() { + d=`ps | grep wifi_daemon | grep -v grep` + [ -n "$d" ] && { + killall wifi_daemon + sleep 1 + } + + /etc/init.d/wpa_supplicant stop + + rfkill.elf block wifi +} + +case "$1" in + start|"") + start + ;; + stop) + stop + ;; + *) + echo "Usage: $0 {start|stop}" + exit 1 +esac \ No newline at end of file diff --git a/skeleton/SYSTEM/my355/lib/.keep b/skeleton/SYSTEM/my355/lib/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/skeleton/SYSTEM/my355/paks/Emus/FC.pak/default.cfg b/skeleton/SYSTEM/my355/paks/Emus/FC.pak/default.cfg new file mode 100755 index 000000000..90365a9d1 --- /dev/null +++ b/skeleton/SYSTEM/my355/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/my355/paks/Emus/FC.pak/launch.sh b/skeleton/SYSTEM/my355/paks/Emus/FC.pak/launch.sh new file mode 100755 index 000000000..eed3503dc --- /dev/null +++ b/skeleton/SYSTEM/my355/paks/Emus/FC.pak/launch.sh @@ -0,0 +1,13 @@ +#!/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" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" > "$LOGS_PATH/$EMU_TAG.txt" 2>&1 diff --git a/skeleton/SYSTEM/my355/paks/Emus/GB.pak/default.cfg b/skeleton/SYSTEM/my355/paks/Emus/GB.pak/default.cfg new file mode 100755 index 000000000..a5ec62866 --- /dev/null +++ b/skeleton/SYSTEM/my355/paks/Emus/GB.pak/default.cfg @@ -0,0 +1,20 @@ +minarch_screen_scaling = 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/my355/paks/Emus/GB.pak/launch.sh b/skeleton/SYSTEM/my355/paks/Emus/GB.pak/launch.sh new file mode 100755 index 000000000..132e824d8 --- /dev/null +++ b/skeleton/SYSTEM/my355/paks/Emus/GB.pak/launch.sh @@ -0,0 +1,13 @@ +#!/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" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" > "$LOGS_PATH/$EMU_TAG.txt" 2>&1 diff --git a/skeleton/SYSTEM/my355/paks/Emus/GBA.pak/default.cfg b/skeleton/SYSTEM/my355/paks/Emus/GBA.pak/default.cfg new file mode 100755 index 000000000..ea76e21f6 --- /dev/null +++ b/skeleton/SYSTEM/my355/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/my355/paks/Emus/GBA.pak/launch.sh b/skeleton/SYSTEM/my355/paks/Emus/GBA.pak/launch.sh new file mode 100755 index 000000000..eea82389b --- /dev/null +++ b/skeleton/SYSTEM/my355/paks/Emus/GBA.pak/launch.sh @@ -0,0 +1,13 @@ +#!/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" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" > "$LOGS_PATH/$EMU_TAG.txt" 2>&1 diff --git a/skeleton/SYSTEM/my355/paks/Emus/GBC.pak/default.cfg b/skeleton/SYSTEM/my355/paks/Emus/GBC.pak/default.cfg new file mode 100755 index 000000000..c854f885e --- /dev/null +++ b/skeleton/SYSTEM/my355/paks/Emus/GBC.pak/default.cfg @@ -0,0 +1,17 @@ +minarch_screen_scaling = Native + +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/my355/paks/Emus/GBC.pak/launch.sh b/skeleton/SYSTEM/my355/paks/Emus/GBC.pak/launch.sh new file mode 100755 index 000000000..132e824d8 --- /dev/null +++ b/skeleton/SYSTEM/my355/paks/Emus/GBC.pak/launch.sh @@ -0,0 +1,13 @@ +#!/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" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" > "$LOGS_PATH/$EMU_TAG.txt" 2>&1 diff --git a/skeleton/SYSTEM/my355/paks/Emus/MD.pak/default.cfg b/skeleton/SYSTEM/my355/paks/Emus/MD.pak/default.cfg new file mode 100755 index 000000000..dac408932 --- /dev/null +++ b/skeleton/SYSTEM/my355/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/my355/paks/Emus/MD.pak/launch.sh b/skeleton/SYSTEM/my355/paks/Emus/MD.pak/launch.sh new file mode 100755 index 000000000..bfb54a087 --- /dev/null +++ b/skeleton/SYSTEM/my355/paks/Emus/MD.pak/launch.sh @@ -0,0 +1,13 @@ +#!/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" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" > "$LOGS_PATH/$EMU_TAG.txt" 2>&1 diff --git a/skeleton/SYSTEM/my355/paks/Emus/PS.pak/default.cfg b/skeleton/SYSTEM/my355/paks/Emus/PS.pak/default.cfg new file mode 100755 index 000000000..857e895eb --- /dev/null +++ b/skeleton/SYSTEM/my355/paks/Emus/PS.pak/default.cfg @@ -0,0 +1,22 @@ +-minarch_thread_video = Off + +-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/my355/paks/Emus/PS.pak/launch.sh b/skeleton/SYSTEM/my355/paks/Emus/PS.pak/launch.sh new file mode 100755 index 000000000..7251806ae --- /dev/null +++ b/skeleton/SYSTEM/my355/paks/Emus/PS.pak/launch.sh @@ -0,0 +1,13 @@ +#!/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" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" > "$LOGS_PATH/$EMU_TAG.txt" 2>&1 diff --git a/skeleton/SYSTEM/my355/paks/Emus/SFC.pak/default.cfg b/skeleton/SYSTEM/my355/paks/Emus/SFC.pak/default.cfg new file mode 100755 index 000000000..8100f20a1 --- /dev/null +++ b/skeleton/SYSTEM/my355/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/my355/paks/Emus/SFC.pak/launch.sh b/skeleton/SYSTEM/my355/paks/Emus/SFC.pak/launch.sh new file mode 100755 index 000000000..2ec573a69 --- /dev/null +++ b/skeleton/SYSTEM/my355/paks/Emus/SFC.pak/launch.sh @@ -0,0 +1,13 @@ +#!/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" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" > "$LOGS_PATH/$EMU_TAG.txt" 2>&1 diff --git a/skeleton/SYSTEM/my355/paks/MinUI.pak/launch.sh b/skeleton/SYSTEM/my355/paks/MinUI.pak/launch.sh new file mode 100755 index 000000000..97ba2b3e4 --- /dev/null +++ b/skeleton/SYSTEM/my355/paks/MinUI.pak/launch.sh @@ -0,0 +1,125 @@ +#!/bin/sh + +export PLATFORM="my355" +export SDCARD_PATH="/mnt/SDCARD" +export BIOS_PATH="$SDCARD_PATH/Bios" +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" +export HOME="$USERDATA_PATH" + +####################################### + +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 DEVICE="my355" + +export IS_NEXT="yes" + +####################################### + +export LD_LIBRARY_PATH=$SYSTEM_PATH/lib:/usr/miyoo/lib:$LD_LIBRARY_PATH +export PATH=$SYSTEM_PATH/bin:/usr/miyoo/bin:/usr/miyoo/sbin:$PATH + +echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" > /mnt/SDCARD/librarypath.txt +####################################### + +#headphone jack +echo 150 > /sys/class/gpio/export +echo -n in > /sys/class/gpio/gpio150/direction + +#motor +echo 20 > /sys/class/gpio/export +echo -n out > /sys/class/gpio/gpio20/direction +echo -n 0 > /sys/class/gpio/gpio20/value + +#keyboard +echo 0 > /sys/class/miyooio_chr_dev/joy_type + +#screen adjustment for now here +modetest -M rockchip -w 179:hue:60 +modetest -M rockchip -w 179:saturation:60 + +#led +echo 100 > /sys/class/leds/work/brightness + +# disable system-level lid handling +mv /dev/input/event1 /dev/input/event1.disabled + +mkdir -p /tmp/miyoo_inputd +miyoo_inputd & + +echo userspace > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor +CPU_PATH=/sys/devices/system/cpu/cpufreq/policy0/scaling_setspeed +CPU_SPEED_PERF=1992000 +echo $CPU_SPEED_PERF > $CPU_PATH + +keymon.elf & # &> $SDCARD_PATH/keymon.txt & +batmon.elf & # &> $SDCARD_PATH/batmon.txt & + +# start fresh, will be populated on the next connect +rm -f $USERDATA_PATH/.asoundrc +audiomon.elf & # &> $SDCARD_PATH/audiomon.txt & + +# wifi handling +/etc/init.d/S36load_wifi_modules start +/etc/init.d/S40network start +/etc/init.d/S41dhcpcd start + +wpa_supplicant -B -i wlan0 -c /userdata/cfg/wpa_supplicant.conf +dhcpcd wlan0 + +####################################### + +AUTO_PATH="$USERDATA_PATH/auto.sh" +if [ -f "$AUTO_PATH" ]; then + "$AUTO_PATH" # > $LOGS_PATH/auto.txt 2>&1 +fi + +cd $(dirname "$0") + +####################################### + +# kill show2.elf if running +killall -9 show2.elf > /dev/null 2>&1 + +EXEC_PATH="/tmp/nextui_exec" +NEXT_PATH="/tmp/next" +touch "$EXEC_PATH" && sync + +# Enable audio idk why have to do this now +tinymix set 1 SPK + +while [ -f "$EXEC_PATH" ]; do + nextui.elf &> $LOGS_PATH/nextui.txt + echo $CPU_SPEED_PERF > $CPU_PATH + + if [ -f $NEXT_PATH ]; then + CMD=`cat $NEXT_PATH` + eval $CMD + rm -f $NEXT_PATH + echo $CPU_SPEED_PERF > $CPU_PATH + fi + + if [ -f "/tmp/poweroff" ]; then + shutdown + exit 0 + fi + if [ -f "/tmp/reboot" ]; then + reboot + exit 0 + fi +done + +shutdown diff --git a/skeleton/SYSTEM/my355/shaders/colorfix.glsl b/skeleton/SYSTEM/my355/shaders/colorfix.glsl new file mode 100644 index 000000000..20a129919 --- /dev/null +++ b/skeleton/SYSTEM/my355/shaders/colorfix.glsl @@ -0,0 +1,21 @@ +#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) +precision mediump float; +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/my355/shaders/default.glsl b/skeleton/SYSTEM/my355/shaders/default.glsl new file mode 100644 index 000000000..539ab8478 --- /dev/null +++ b/skeleton/SYSTEM/my355/shaders/default.glsl @@ -0,0 +1,21 @@ +#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) +precision mediump float; +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/my355/shaders/noshader.glsl b/skeleton/SYSTEM/my355/shaders/noshader.glsl new file mode 100644 index 000000000..539ab8478 --- /dev/null +++ b/skeleton/SYSTEM/my355/shaders/noshader.glsl @@ -0,0 +1,21 @@ +#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) +precision mediump float; +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/my355/shaders/overlay.glsl b/skeleton/SYSTEM/my355/shaders/overlay.glsl new file mode 100644 index 000000000..5672d1a90 --- /dev/null +++ b/skeleton/SYSTEM/my355/shaders/overlay.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) +precision mediump float; +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/my355/system.cfg b/skeleton/SYSTEM/my355/system.cfg new file mode 100644 index 000000000..3d8dda39d --- /dev/null +++ b/skeleton/SYSTEM/my355/system.cfg @@ -0,0 +1,20 @@ +minarch_screen_scaling = Aspect +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/common/api.c b/workspace/all/common/api.c index 18c947d45..297ba045b 100644 --- a/workspace/all/common/api.c +++ b/workspace/all/common/api.c @@ -1836,7 +1836,7 @@ int GFX_blitHardwareGroup(SDL_Surface *dst, int show_setting) ox += SCALE1(PILL_SIZE); oy += SCALE1((PILL_SIZE - SETTINGS_SIZE) / 2); - GFX_blitPillColor(gfx.mode == MODE_MAIN ? ASSET_BAR_BG : ASSET_BAR_BG_MENU, dst, &(SDL_Rect){ox, oy, SCALE1(SETTINGS_WIDTH), SCALE1(SETTINGS_SIZE)}, + GFX_blitPillColor(gfx.mode == MODE_MAIN ? ASSET_BAR_BG : ASSET_BAR_BG_MENU, dst, &(SDL_Rect){ox, oy, SCALE1(SETTINGS_WIDTH), SCALE1(SETTINGS_SIZE)}, THEME_COLOR3, RGB_WHITE); float percent = ((float)(setting_value - setting_min) / (setting_max - setting_min)); @@ -2398,7 +2398,7 @@ size_t SND_batchSamples(const SND_Frame *frames, size_t frame_count) SND_pauseAudio(false); } else if (perf.buffer_free > snd.frame_count * 0.99f) { // if for some reason buffer drops below threshold again, pause it (like psx core can stop sending audio in between scenes or after fast forward etc) SND_pauseAudio(true); - } + } float tempdelay = ((snd.frame_count - remaining_space) / snd.sample_rate_out) * 1000.0f; @@ -2519,7 +2519,7 @@ size_t SND_batchSamples_fixed_rate(const SND_Frame *frames, size_t frame_count) SND_pauseAudio(false); } else if (perf.buffer_free > snd.frame_count * 0.99f) { // if for some reason buffer drops below 1% again, pause audio again (like psx core can stop sending audio in between scenes or after fast forward etc) SND_pauseAudio(true); - } + } float tempdelay = ((snd.frame_count - remaining_space) / snd.sample_rate_out) * 1000; perf.buffer_ms = tempdelay; @@ -3962,7 +3962,7 @@ void LEDS_applyRules() LOG_error("LEDS_applyRules: lights not initialized, skipping\n"); return; } - + // some rules rely on pwr.is_charging and pwr.charge being valid if(pwr.initialized == 0) LOG_warn("LEDS_applyRules called before PWR_init\n"); @@ -4007,7 +4007,7 @@ void LEDS_updateLeds(bool indicator_only) LOG_error("LEDS_updateLeds: lights not initialized, skipping\n"); return; } - + int lightsize = 3; char *device = getenv("DEVICE"); int is_brick = exactMatch("brick", device); @@ -4067,7 +4067,7 @@ void LEDS_initLeds() lightsCharging[i] = lightsDefault[i]; lightsCharging[i].effect = 2; // breathe lightsCharging[i].color1 = 0x00FF00; - lightsCharging[i].cycles = -1; // infinite + lightsCharging[i].cycles = -1; // infinite // LIGHT_PROFILE_SLEEP lightsSleep[i] = lightsDefault[i]; @@ -4218,4 +4218,4 @@ FALLBACK_IMPLEMENTATION void PLAT_bluetoothStreamBegin(int buffersize) {} FALLBACK_IMPLEMENTATION void PLAT_bluetoothStreamEnd() {} FALLBACK_IMPLEMENTATION void PLAT_bluetoothStreamQuit() {} FALLBACK_IMPLEMENTATION int PLAT_bluetoothVolume() { return 100; } -FALLBACK_IMPLEMENTATION void PLAT_bluetoothSetVolume(int vol) {} \ No newline at end of file +FALLBACK_IMPLEMENTATION void PLAT_bluetoothSetVolume(int vol) {} diff --git a/workspace/all/common/api.h b/workspace/all/common/api.h index b518f2664..542454885 100644 --- a/workspace/all/common/api.h +++ b/workspace/all/common/api.h @@ -130,9 +130,9 @@ enum { ASSET_UNDERLINE, ASSET_DOT, ASSET_HOLE, - + ASSET_COLORS, - + ASSET_BRIGHTNESS, ASSET_COLORTEMP, ASSET_VOLUME_MUTE, @@ -142,10 +142,10 @@ enum { ASSET_BATTERY_FILL, ASSET_BATTERY_FILL_LOW, ASSET_BATTERY_BOLT, - + ASSET_SCROLL_UP, ASSET_SCROLL_DOWN, - + ASSET_WIFI, ASSET_WIFI_MED, ASSET_WIFI_LOW, @@ -155,7 +155,7 @@ enum { ASSET_BLUETOOTH_OFF, ASSET_AUDIO, ASSET_CONTROLLER, - + ASSET_CHECKCIRCLE, ASSET_LOCK, ASSET_SETTINGS, @@ -164,7 +164,7 @@ enum { ASSET_POWEROFF, ASSET_RESTART, ASSET_SUSPEND, - + ASSET_COUNT, }; @@ -196,7 +196,7 @@ typedef struct GFX_Renderer { void* blit; double aspect; // 0 for integer, -1 for fullscreen, otherwise aspect ratio, used for SDL2 accelerated scaling int scale; - + // TODO: document this better int true_w; int true_h; @@ -206,7 +206,7 @@ typedef struct GFX_Renderer { int src_w; int src_h; int src_p; - + // TODO: I think this is overscaled int dst_x; int dst_y; @@ -523,7 +523,7 @@ void LEDS_initLeds(); void LEDS_applyRules(); // temporary overrides outside of the scope of LEDS_applyRules -// these will survive LEDS_applyRules() and need to be manually revoked, e.g. +// these will survive LEDS_applyRules() and need to be manually revoked, e.g. /* LEDS_applyRules(); // applies rules LEDS_pushProfile(LIGHT_PROFILE_AMBIENT); // manual override @@ -751,7 +751,7 @@ void PLAT_wifiForget(char *ssid, WifiSecurityType sec); // attempt to connect to this SSID, using, stored credentials. // \sa PLAT_wifiHasCredentials void PLAT_wifiConnect(char *ssid, WifiSecurityType sec); -// attempt to connect to this SSID with password given. +// attempt to connect to this SSID with password given. // If successful, stores credentials with wpa_supplicant. void PLAT_wifiConnectPass(const char *ssid, WifiSecurityType sec, const char* pass); // disconnect from any active network diff --git a/workspace/all/minarch/makefile b/workspace/all/minarch/makefile index e65dee0f6..44955d360 100644 --- a/workspace/all/minarch/makefile +++ b/workspace/all/minarch/makefile @@ -47,10 +47,15 @@ else LDFLAGS += -lzip endif # Linux else # all handheld platfoms +ifeq ($(PLATFORM), my355) +LDFLAGS += -Llibretro-common -lsrm -lzip +CFLAGS += -DHAS_SRM +else LDFLAGS += -Llibretro-common -lsrm -lzip CFLAGS += -DHAS_SRM LDFLAGS += -lasound endif +endif # CFLAGS += -Wall -Wno-unused-variable -Wno-unused-function -Wno-format-overflow @@ -72,6 +77,14 @@ BUILD_DATE!=date +%Y.%m.%d BUILD_HASH!=cat ../../hash.txt CFLAGS += -DBUILD_DATE=\"${BUILD_DATE}\" -DBUILD_HASH=\"${BUILD_HASH}\" +ifeq ($(PLATFORM), my355) +# old toolchain libs +#LIB_PATH=/usr/lib/aarch64-linux-gnu +LIB_PATH=$(PREFIX)/lib +else +LIB_PATH=$(PREFIX)/lib +endif + ifeq ($(PLATFORM), desktop) all: clean libretro-common $(PREFIX_LOCAL)/include/msettings.h mkdir -p build/$(PLATFORM) @@ -79,25 +92,37 @@ all: clean libretro-common $(PREFIX_LOCAL)/include/msettings.h else all: clean libretro-common libsrm.a $(PREFIX_LOCAL)/include/msettings.h mkdir -p build/$(PLATFORM) - cp -L $(PREFIX)/lib/libsamplerate.so.* build/$(PLATFORM) # This is a bandaid fix, needs to be cleaned up if/when we expand to other platforms. +ifeq ($(PLATFORM), my355) + #cp $(LIB_PATH)/libcrypto.so.3 build/$(PLATFORM) + #cp $(LIB_PATH)/libzip.so.4 build/$(PLATFORM) + cp $(LIB_PATH)/libcrypto.so.1.1 build/$(PLATFORM) + cp $(LIB_PATH)/libsamplerate.so.0 build/$(PLATFORM) + cp $(LIB_PATH)/libzip.so.5 build/$(PLATFORM) + cp $(LIB_PATH)/libbz2.so.1.0 build/$(PLATFORM) + cp $(LIB_PATH)/liblzma.so.5 build/$(PLATFORM) + cp $(LIB_PATH)/libzstd.so.1 build/$(PLATFORM) + cp $(LIB_PATH)/libsqlite3.so.0 build/$(PLATFORM) +else + cp -L $(PREFIX)/lib/libsamplerate.so.* build/$(PLATFORM) cp -L $(PREFIX)/lib/libzip.so.* build/$(PLATFORM) cp -L $(PREFIX)/lib/libbz2.so.1.0 build/$(PLATFORM) cp -L $(PREFIX)/lib/liblzma.so.5 build/$(PLATFORM) cp -L $(PREFIX)/lib/libzstd.so.1 build/$(PLATFORM) +endif $(CC) $(SOURCE) -o $(PRODUCT) $(CFLAGS) $(LDFLAGS) endif libretro-common: git clone https://github.com/libretro/libretro-common - + $(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 -$(OBJECTS) : +$(OBJECTS) : cd libretro-common && $(CC) $(CFLAGS) -DHAVE_ZLIB -c -o $@ $(subst .o,.c,$@) -I include/ libsrm.a: $(OBJECTS) diff --git a/workspace/my355/cores/makefile b/workspace/my355/cores/makefile new file mode 100755 index 000000000..a224ff179 --- /dev/null +++ b/workspace/my355/cores/makefile @@ -0,0 +1,131 @@ +CORES= a2600 +CORES+= a5200 +CORES+= a7800 +CORES+= handy +CORES+= c64 +CORES+= c128 +CORES+= fake-08 +CORES+= fbneo +CORES+= fceumm +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 +CORES+= plus4 +CORES+= pokemini +CORES+= race +CORES+= snes9x +CORES+= vic +CORES+= prboom +CORES+= bluemsx +CORES+= gearcoleco + +############################### + +# optional core vars +# *_REPO= +# *_HASH= +# *_CORE= +# *_FLAGS= +# *_MAKEFILE= +# *_BUILD_PATH= +# *_SUBMODULES= + +a2600_REPO = https://github.com/libretro/stella2014-libretro +a2600_CORE = stella2014_libretro.so + +a5200_CORE = a5200_libretro.so + +a7800_CORE = prosystem_libretro.so +a7800_REPO = https://github.com/libretro/prosystem-libretro + +handy_REPO = https://github.com/libretro/libretro-handy + +fbneo_REPO = https://github.com/libretro/FBNeo +fbneo_CORE = fbneo_libretro.so +fbneo_BUILD_PATH = fbneo/src/burner/libretro +fbneo_MAKE = make +fbneo_HASH = 6a5cc250c2db8d874a06ee86e302a2a78918b4c1 + +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 has a disabled submodule for gnulib, which takes forever to check out and is unused - skil checkout +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 = b0be121b7d58d6ee1ee2809974e62893c80a8264 + +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 = 78656d4615691c393e65e48672ce5fff5b1f97d3 + +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_BRANCH = 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 + +bluemsx_REPO = https://github.com/libretro/blueMSX-libretro +bluemsx_CORE = bluemsx_libretro.so +bluemsx_MAKEFILE = Makefile.libretro + +gearcoleco_REPO = https://github.com/drhelius/Gearcoleco.git +gearcoleco_CORE = gearcoleco_libretro.so +gearcoleco_BUILD_PATH = gearcoleco/platforms/libretro + +############################### + +include ../../all/cores/makefile diff --git a/workspace/my355/cores/patches/a2600.patch b/workspace/my355/cores/patches/a2600.patch new file mode 100644 index 000000000..9a1e0fe77 --- /dev/null +++ b/workspace/my355/cores/patches/a2600.patch @@ -0,0 +1,24 @@ +diff --git a/Makefile b/Makefile +index a22eb5d..c55c8cf 100644 +--- a/Makefile ++++ b/Makefile +@@ -383,6 +383,19 @@ else ifeq ($(platform), miyoo) + FLAGS += -fomit-frame-pointer -ffast-math -march=armv5te -mtune=arm926ej-s + fpic := -fPIC + ++# target platform my355 ++else ifeq ($(platform), my355) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CC = $(CROSS_COMPILE)gcc ++ CXX = $(CROSS_COMPILE)g++ ++ AR = $(CROSS_COMPILE)ar ++ SHARED := -shared -Wl,--no-undefined ++ LDFLAGS += -shared -Wl,--version-script=link.T -ffast-math ++ CFLAGS += -DARM -DALIGN_DWORD -falign-functions=16 -pipe -fstack-protector ++ CFLAGS += -mtune=cortex-a55 -mcpu=cortex-a55 -march=armv8.2-a ++ fpic := -fPIC ++ HAVE_NEON = 1 ++ + # Windows MSVC 2003 Xbox 1 + else ifeq ($(platform), xbox1_msvc2003) + TARGET := $(TARGET_NAME)_libretro_xdk1.lib diff --git a/workspace/my355/cores/patches/a5200.patch b/workspace/my355/cores/patches/a5200.patch new file mode 100644 index 000000000..58669f389 --- /dev/null +++ b/workspace/my355/cores/patches/a5200.patch @@ -0,0 +1,23 @@ +diff --git a/Makefile b/Makefile +index 67a7e1f..184ec33 100644 +--- a/Makefile ++++ b/Makefile +@@ -326,6 +326,18 @@ else ifeq ($(platform), miyoo) + FLAGS += -fomit-frame-pointer -ffast-math -mcpu=arm926ej-s + fpic := -fPIC + ++# target platform my355 ++else ifeq ($(platform), my355) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CC = $(CROSS_COMPILE)gcc ++ CXX = $(CROSS_COMPILE)g++ ++ AR = $(CROSS_COMPILE)ar ++ SHARED := -shared -Wl,--no-undefined ++ LDFLAGS += -shared -Wl,--version-script=link.T ++ FLAGS += -fomit-frame-pointer -ffast-math -mtune=cortex-a55 -mcpu=cortex-a55 -march=armv8.2-a ++ fpic := -fPIC ++ HAVE_NEON = 1 ++ + # Raspberry Pi 1 + else ifeq ($(platform), rpi1) + TARGET := $(TARGET_NAME)_libretro.so diff --git a/workspace/my355/cores/patches/a7800.patch b/workspace/my355/cores/patches/a7800.patch new file mode 100644 index 000000000..b4aa19764 --- /dev/null +++ b/workspace/my355/cores/patches/a7800.patch @@ -0,0 +1,23 @@ +diff --git a/Makefile b/Makefile +index dc2a31c..2a8bca2 100644 +--- a/Makefile ++++ b/Makefile +@@ -328,6 +328,18 @@ else ifeq ($(platform), miyoo) + FLAGS += -fomit-frame-pointer -ffast-math -march=armv5te -mtune=arm926ej-s + fpic := -fPIC + ++# target platform my355 trimUI brick ++else ifeq ($(platform), my355) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CC = $(CROSS_COMPILE)gcc ++ CXX = $(CROSS_COMPILE)g++ ++ AR = $(CROSS_COMPILE)ar ++ SHARED := -shared -Wl,--no-undefined ++ LDFLAGS += -shared -Wl,--version-script=link.T ++ FLAGS += -fomit-frame-pointer -ffast-math -mtune=cortex-a55 -mcpu=cortex-a55 -march=armv8.2-a ++ fpic := -fPIC ++ HAVE_NEON = 1 ++ + # Raspberry Pi 1 + else ifeq ($(platform), rpi1) + TARGET := $(TARGET_NAME)_libretro.so diff --git a/workspace/my355/cores/patches/bluemsx.patch b/workspace/my355/cores/patches/bluemsx.patch new file mode 100644 index 000000000..d015c035c --- /dev/null +++ b/workspace/my355/cores/patches/bluemsx.patch @@ -0,0 +1,30 @@ +diff --git a/Makefile.libretro b/Makefile.libretro +index 6f412c7..9a8a14a 100644 +--- a/Makefile.libretro ++++ b/Makefile.libretro +@@ -188,6 +188,25 @@ else ifeq ($(platform), classic_armv8_a35) + LDFLAGS += -marm -mcpu=cortex-a35 -mfpu=neon-fp-armv8 -mfloat-abi=hard -Ofast -flto -fuse-linker-plugin + ####################################### + ++# (Miyoo Flip) ### ++else ifeq ($(platform), my355) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CC = $(CROSS_COMPILE)gcc ++ CXX = $(CROSS_COMPILE)g++ ++ AR = $(CROSS_COMPILE)ar ++ fpic := -fPIC ++ SHARED := -shared -Wl,-version-script=link.T -Wl,-no-undefined ++ CFLAGS += -Ofast \ ++ -fuse-linker-plugin \ ++ -fno-stack-protector -fno-ident -fomit-frame-pointer \ ++ -fmerge-all-constants -ffast-math -funroll-all-loops \ ++ -mtune=cortex-a55 -mcpu=cortex-a55 -march=armv8.2-a ++ CPPFLAGS += $(CFLAGS) ++ HAVE_NEON = 1 ++ LDFLAGS += -lrt ++ LDFLAGS += -mtune=cortex-a55 -mcpu=cortex-a55 -march=armv8.2-a -Ofast -flto -fuse-linker-plugin ++####################################### ++ + # OS X + else ifeq ($(platform), osx) + TARGET := $(TARGET_NAME)_libretro.dylib diff --git a/workspace/my355/cores/patches/c128.patch b/workspace/my355/cores/patches/c128.patch new file mode 100644 index 000000000..042b15e62 --- /dev/null +++ b/workspace/my355/cores/patches/c128.patch @@ -0,0 +1,21 @@ +diff --git a/Makefile b/Makefile +index 62cb321..e50aa6e 100644 +--- a/Makefile ++++ b/Makefile +@@ -380,6 +380,16 @@ else ifneq (,$(findstring armv,$(platform))) + endif + CFLAGS += -DARM -marm -DALIGN_DWORD -mthumb-interwork -falign-functions=16 -pipe -fstack-protector + ++# TrimUI Brick ++else ifeq ($(platform), my355) ++ TARGET := $(TARGET_NAME)_libretro.so ++ fpic := -fPIC ++ SHARED := -shared -Wl,--no-undefined ++ LDFLAGS += -shared -Wl,--version-script=$(CORE_DIR)/libretro/link.T ++ HAVE_NEON = 1 ++ CFLAGS += -DARM -DALIGN_DWORD -falign-functions=16 -pipe -fstack-protector ++ CFLAGS += -mtune=cortex-a55 -mcpu=cortex-a55 -march=armv8.2-a ++ + # Wincross64 + else ifeq ($(platform), wincross64) + AR = x86_64-w64-mingw32-ar diff --git a/workspace/my355/cores/patches/c64.patch b/workspace/my355/cores/patches/c64.patch new file mode 100644 index 000000000..042b15e62 --- /dev/null +++ b/workspace/my355/cores/patches/c64.patch @@ -0,0 +1,21 @@ +diff --git a/Makefile b/Makefile +index 62cb321..e50aa6e 100644 +--- a/Makefile ++++ b/Makefile +@@ -380,6 +380,16 @@ else ifneq (,$(findstring armv,$(platform))) + endif + CFLAGS += -DARM -marm -DALIGN_DWORD -mthumb-interwork -falign-functions=16 -pipe -fstack-protector + ++# TrimUI Brick ++else ifeq ($(platform), my355) ++ TARGET := $(TARGET_NAME)_libretro.so ++ fpic := -fPIC ++ SHARED := -shared -Wl,--no-undefined ++ LDFLAGS += -shared -Wl,--version-script=$(CORE_DIR)/libretro/link.T ++ HAVE_NEON = 1 ++ CFLAGS += -DARM -DALIGN_DWORD -falign-functions=16 -pipe -fstack-protector ++ CFLAGS += -mtune=cortex-a55 -mcpu=cortex-a55 -march=armv8.2-a ++ + # Wincross64 + else ifeq ($(platform), wincross64) + AR = x86_64-w64-mingw32-ar diff --git a/workspace/my355/cores/patches/fake-08.patch b/workspace/my355/cores/patches/fake-08.patch new file mode 100755 index 000000000..5ee562f0e --- /dev/null +++ b/workspace/my355/cores/patches/fake-08.patch @@ -0,0 +1,22 @@ +diff --git forkSrcPrefix/platform/libretro/Makefile forkDstPrefix/platform/libretro/Makefile +index be0f1b46bb3ab10be4a9f896f5e8841dd630b35b..f6b4d892627ec2a81b01ddb4da7f0c7a8022221f 100644 +--- forkSrcPrefix/platform/libretro/Makefile ++++ forkDstPrefix/platform/libretro/Makefile +@@ -123,7 +123,16 @@ else ifeq ($(platform), miyoomini) + CXXFLAGS += -marm -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -march=armv7ve -D_NEED_FULL_PATH_ + fpic := -fPIC + SHARED := -shared -Wl,--version-script=link.T +- ++# MIYOO FLIP ++else ifeq ($(platform), my355) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CC = $(CROSS_COMPILE)gcc ++ CXX = $(CROSS_COMPILE)g++ ++ AR = $(CROSS_COMPILE)ar ++ STRIP = $(CROSS_COMPILE)strip ++ CXXFLAGS += -mcpu=cortex-a55 -mtune=cortex-a55 ++ fpic := -fPIC ++ SHARED := -shared -Wl,--version-script=link.T + else ifeq ($(platform), gcw0) + TARGET := $(TARGET_NAME)_libretro_gcw0.so + CC = /opt/gcw0-toolchain/usr/bin/mipsel-linux-gcc diff --git a/workspace/my355/cores/patches/fbneo.patch b/workspace/my355/cores/patches/fbneo.patch new file mode 100644 index 000000000..66e953e07 --- /dev/null +++ b/workspace/my355/cores/patches/fbneo.patch @@ -0,0 +1,108 @@ +diff --git a/src/burner/libretro/Makefile b/src/burner/libretro/Makefile +old mode 100644 +new mode 100755 +index 0b7d646c7..2784aa150 +--- a/src/burner/libretro/Makefile ++++ b/src/burner/libretro/Makefile +@@ -346,6 +346,22 @@ else ifeq ($(platform), classic_armv7_a7) + CFLAGS += $(PLATFORM_FLAGS) + CXXFLAGS += $(PLATFORM_FLAGS) + ++# target platform my355 ++else ifneq (,$(findstring my355,$(platform))) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CXX=$(CROSS_COMPILE)gcc ++ fpic := -fPIC ++ SHARED := -shared -Wl,-no-undefined -Wl,--version-script=$(VERSION_SCRIPT) ++ PLATFORM_FLAGS := -O3 -Ofast -DNDEBUG=1 -fomit-frame-pointer -ffast-math -mtune=cortex-a55 -mcpu=cortex-a55 -march=armv8.2-a+simd ++ USE_EXPERIMENTAL_FLAGS = 0 ++ HAVE_NEON = 0 ++ USE_CYCLONE = 0 ++ ARCH = arm ++ ENDIANNESS_DEFINES := -DLSB_FIRST ++ LDFLAGS += -lstdc++ -static-libgcc -static-libstdc++ -lpthread -lm -flto ++ CFLAGS += $(PLATFORM_FLAGS) ++ CXXFLAGS += $(PLATFORM_FLAGS) ++ + # (armv8 a35, hard point, neon based) ### + # Playstation Classic + else ifeq ($(platform), classic_armv8_a35) +diff --git a/src/burner/libretro/libretro.cpp b/src/burner/libretro/libretro.cpp +index 3726ec60f..30a6c8cd6 100644 +--- a/src/burner/libretro/libretro.cpp ++++ b/src/burner/libretro/libretro.cpp +@@ -78,7 +78,7 @@ INT32 nAudSegLen = 0; + + static UINT8* pVidImage = NULL; + static bool bVidImageNeedRealloc = false; +-static bool bRotationDone = false; ++static bool bRotationDone = true; + static int16_t *pAudBuffer = NULL; + static char text_missing_files[2048] = ""; + +@@ -1550,8 +1550,46 @@ void retro_run() + // current frame will be corrupted, let's dupe instead + pBurnDraw = NULL; + } ++ // get flags ++ UINT32 flags = BurnDrvGetFlags(); ++ ++ if (pBurnDraw && flags & BDF_ORIENTATION_VERTICAL) { ++ int y=0; ++ ++ UINT8 *pTMP = (UINT8*)malloc(nGameWidth * nGameHeight * nBurnBpp); ++ memcpy(pTMP, pBurnDraw, nGameWidth * nGameHeight * nBurnBpp); ++ ++ int newGameWidth = nGameHeight; ++ int newGameHeight = nGameWidth; ++ int newBurnPitch = newGameWidth * nBurnBpp; ++ ++ if ((BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL)) ++ while (y < newGameHeight) { ++ int x = 0; ++ ++ if ( flags & BDF_ORIENTATION_FLIPPED ) { ++ while (x < newGameWidth) ++ { ++ for (int i = 0; i < nBurnBpp; i++) ++ pBurnDraw[x * nBurnBpp + y * newBurnPitch + i] = pTMP[(nGameHeight - x - 1) * nBurnPitch + y * nBurnBpp + i]; ++ x++; ++ } ++ } else { ++ while (x < newGameWidth) ++ { ++ for (int i = 0; i < nBurnBpp; i++) ++ pBurnDraw[x * nBurnBpp + y * newBurnPitch + i] = pTMP[x * nBurnPitch + (nGameWidth - y - 1) * nBurnBpp + i]; ++ x++; ++ } ++ } ++ y++; ++ } ++ free(pTMP); ++ video_cb(pBurnDraw, newGameWidth, newGameHeight, newBurnPitch); ++ } else { ++ video_cb(pBurnDraw, nGameWidth, nGameHeight, nBurnPitch); ++ } + +- video_cb(pBurnDraw, nGameWidth, nGameHeight, nBurnPitch); + + bool updated = false; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated) +@@ -1567,7 +1605,7 @@ void retro_run() + // change orientation/geometry if vertical mode was toggled on/off + if (old_nVerticalMode != nVerticalMode) + { +- SetRotation(); ++ //SetRotation(); + struct retro_system_av_info av_info; + retro_get_system_av_info(&av_info); + environ_cb(RETRO_ENVIRONMENT_SET_GEOMETRY, &av_info); +@@ -2184,7 +2222,7 @@ static bool retro_load_game_common() + + // Initializing display, autorotate if needed + BurnDrvGetFullSize(&nGameWidth, &nGameHeight); +- SetRotation(); ++ //SetRotation(); + SetColorDepth(); + + VideoBufferInit(); diff --git a/workspace/my355/cores/patches/fceumm.patch b/workspace/my355/cores/patches/fceumm.patch new file mode 100755 index 000000000..471f98aca --- /dev/null +++ b/workspace/my355/cores/patches/fceumm.patch @@ -0,0 +1,28 @@ +diff --git forkSrcPrefix/Makefile.libretro forkDstPrefix/Makefile.libretro +index 036c41f48b087c99b2276b2d41a71d661fd85145..891eb96ceeb1da868d6d2ed40392b51b65dcbb20 100644 +--- forkSrcPrefix/Makefile.libretro ++++ forkDstPrefix/Makefile.libretro +@@ -461,6 +461,23 @@ else ifeq ($(platform), miyoo) + PLATFORM_DEFINES += -fomit-frame-pointer -ffast-math -mcpu=arm926ej-s + EXTERNAL_ZLIB = 1 + ++# MIYOO FLIP ++else ifeq ($(platform), my355) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CC = $(CROSS_COMPILE)gcc ++ CXX = $(CROSS_COMPILE)g++ ++ AR = $(CROSS_COMPILE)ar ++ SHARED := -shared -Wl,--version-script=src/drivers/libretro/link.T -Wl,-no-undefined ++ LDFLAGS += -fPIC -flto ++ CFLAGS += -mcpu=cortex-a55 -mtune=cortex-a55 ++ CFLAGS += -fomit-frame-pointer -ffast-math -fPIC -flto ++ OPTIMIZE := -Ofast -DNDEBUG ++ EXTERNAL_ZLIB = 1 ++ HAVE_NTSC = 0 ++ ifeq (,$(DEBUG)) ++ # LDFLAGS += -s ++ endif ++ + # Windows MSVC 2017 all architectures + else ifneq (,$(findstring windows_msvc2017,$(platform))) + CC = cl.exe diff --git a/workspace/my355/cores/patches/gambatte.patch b/workspace/my355/cores/patches/gambatte.patch new file mode 100755 index 000000000..c20b7a0cc --- /dev/null +++ b/workspace/my355/cores/patches/gambatte.patch @@ -0,0 +1,24 @@ +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) + ++# MIYOO FLIP ++else ifeq ($(platform), my355) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CC = $(CROSS_COMPILE)gcc ++ CXX = $(CROSS_COMPILE)g++ ++ AR = $(CROSS_COMPILE)ar ++ SHARED := -shared -Wl,--version-script=$(version_script) ++ LDFLAGS += -fPIC -flto ++ PLATFORM_DEFINES := -DCC_RESAMPLER -DCC_RESAMPLER_NO_HIGHPASS ++ CFLAGS += -mcpu=cortex-a55 -mtune=cortex-a55 ++ CFLAGS += -fomit-frame-pointer -ffast-math -fPIC -flto ++ CXXFLAGS += $(CFLAGS) ++ + # RETROFW + else ifeq ($(platform), retrofw) + TARGET := $(TARGET_NAME)_libretro.so diff --git a/workspace/my355/cores/patches/gearcoleco.patch b/workspace/my355/cores/patches/gearcoleco.patch new file mode 100644 index 000000000..392c33b25 --- /dev/null +++ b/workspace/my355/cores/patches/gearcoleco.patch @@ -0,0 +1,29 @@ +diff --git a/platforms/libretro/Makefile b/platforms/libretro/Makefile +index 581ee84..d9db102 100644 +--- a/platforms/libretro/Makefile ++++ b/platforms/libretro/Makefile +@@ -274,6 +274,24 @@ else ifeq ($(platform), miyoo) + PLATFORM_DEFINES := -DCC_RESAMPLER -DCC_RESAMPLER_NO_HIGHPASS + CFLAGS += -fomit-frame-pointer -ffast-math -march=armv5te -mtune=arm926ej-s + CXXFLAGS += $(CFLAGS) ++# Miyoo FLip ++else ifeq ($(platform), my355) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CC = $(CROSS_COMPILE)gcc ++ CXX = $(CROSS_COMPILE)g++ ++ AR = $(CROSS_COMPILE)ar ++ fpic := -fPIC ++ SHARED := -shared -Wl,-version-script=$(CORE_DIR)/link.T ++ PLATFORM_DEFINES := -DCC_RESAMPLER -DCC_RESAMPLER_NO_HIGHPASS ++ CFLAGS += -Ofast \ ++ -fuse-linker-plugin -fPIC \ ++ -fno-stack-protector -fno-ident -fomit-frame-pointer \ ++ -fmerge-all-constants -ffast-math -funroll-all-loops \ ++ -mtune=cortex-a55 -mcpu=cortex-a55 -march=armv8.2-a ++ CXXFLAGS += $(CFLAGS) ++ HAVE_NEON = 1 ++ USE_DYNAREC = 1 ++ LDFLAGS += -mtune=cortex-a55 -mcpu=cortex-a55 -march=armv8.2-a -Ofast -fPIC -flto -fuse-linker-plugin + # PS2 + else ifeq ($(platform), ps2) + TARGET := $(TARGET_NAME)_libretro_$(platform).a diff --git a/workspace/my355/cores/patches/gpsp.patch b/workspace/my355/cores/patches/gpsp.patch new file mode 100755 index 000000000..343623ef1 --- /dev/null +++ b/workspace/my355/cores/patches/gpsp.patch @@ -0,0 +1,26 @@ +diff --git forkSrcPrefix/Makefile forkDstPrefix/Makefile +index dc4b60dec7f70a153dbc2eb849cd5acfc90f9d4d..94c7f8dd037284153b6858730a10b6aaaafd5ad4 100644 +--- forkSrcPrefix/Makefile ++++ forkDstPrefix/Makefile +@@ -524,6 +524,21 @@ else ifeq ($(platform), miyoomini) + ARCH = arm + BUILTIN_GPU = neon + ++# MIYOO FLIP ++else ifeq ($(platform), my355) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CC = $(CROSS_COMPILE)gcc ++ CXX = $(CROSS_COMPILE)g++ ++ AR = $(CROSS_COMPILE)ar ++ SHARED := -shared -Wl,--version-script=link.T ++ fpic := -fPIC -DPIC ++ CFLAGS += -fomit-frame-pointer -ffast-math ++ CFLAGS += -mcpu=cortex-a55 -mtune=cortex-a55 ++ ARCH = arm64 ++ CPU_ARCH := arm64 ++ MMAP_JIT_CACHE = 1 ++ HAVE_DYNAREC = 1 ++ + # Windows + else + TARGET := $(TARGET_NAME)_libretro.dll diff --git a/workspace/my355/cores/patches/handy.patch b/workspace/my355/cores/patches/handy.patch new file mode 100644 index 000000000..2b11ea995 --- /dev/null +++ b/workspace/my355/cores/patches/handy.patch @@ -0,0 +1,22 @@ +diff --git a/Makefile b/Makefile +index 088c344..9573f27 100644 +--- a/Makefile ++++ b/Makefile +@@ -270,6 +270,17 @@ else ifeq ($(platform), gcw0) + SHARED := -shared -Wl,--no-undefined -Wl,-version-script=$(LIBRETRO_DIR)/link.T + FLAGS += -DDINGUX -fomit-frame-pointer -ffast-math -march=armv5te -mtune=arm926ej-s + ++# target platform my355 trimUI brick ++else ifeq ($(platform), my355) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CC = $(CROSS_COMPILE)gcc ++ CXX = $(CROSS_COMPILE)g++ ++ AR = $(CROSS_COMPILE)ar ++ fpic := -fPIC ++ SHARED := -shared -Wl,--no-undefined -Wl,-version-script=$(LIBRETRO_DIR)/link.T ++ FLAGS += -fomit-frame-pointer -ffast-math -mtune=cortex-a55 -mcpu=cortex-a55 -march=armv8.2-a ++ HAVE_NEON = 1 ++ + # Nintendo Switch (libnx) + else ifeq ($(platform), libnx) + include $(DEVKITPRO)/libnx/switch_rules diff --git a/workspace/my355/cores/patches/libretro-cap32.patch b/workspace/my355/cores/patches/libretro-cap32.patch new file mode 100644 index 000000000..13258f1f0 --- /dev/null +++ b/workspace/my355/cores/patches/libretro-cap32.patch @@ -0,0 +1,29 @@ +diff --git a/Makefile b/Makefile +index 1aa1720..228fb6b 100644 +--- a/Makefile ++++ b/Makefile +@@ -390,6 +390,24 @@ else ifeq ($(platform), miyoo) + CFLAGS += -funsafe-math-optimizations -fsingle-precision-constant -fexpensive-optimizations + CFLAGS += -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops + ++# TrimUI Brick ++else ifeq ($(platform), my355) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CC = $(CROSS_COMPILE)gcc ++ CXX = $(CROSS_COMPILE)g++ ++ AR = $(CROSS_COMPILE)ar ++ SHARED := -shared -Wl,--version-script=link.T -Wl,-no-undefined ++ LDFLAGS += -fPIC -flto ++ CFLAGS := -DFRONTEND_SUPPORTS_RGB565 -DINLINE="inline" -DM16BPP ++ CFLAGS += -ffast-math ++ CFLAGS += -falign-functions=1 -falign-jumps=1 -falign-loops=1 ++ CFLAGS += -fomit-frame-pointer -ffast-math ++ CFLAGS += -funsafe-math-optimizations -fsingle-precision-constant -fexpensive-optimizations ++ CFLAGS += -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops ++ CFLAGS += -mtune=cortex-a55 -mcpu=cortex-a55 -march=armv8.2-a ++ CFLAGS += -fomit-frame-pointer -ffast-math -fPIC -flto ++ OPTIMIZE := -Ofast -DNDEBUG ++ + # emscripten + else ifeq ($(platform), emscripten) + TARGET := $(TARGET_NAME)_libretro_$(platform).bc diff --git a/workspace/my355/cores/patches/libretro-uae.patch b/workspace/my355/cores/patches/libretro-uae.patch new file mode 100644 index 000000000..d19aada1a --- /dev/null +++ b/workspace/my355/cores/patches/libretro-uae.patch @@ -0,0 +1,45 @@ +diff --git a/Makefile b/Makefile +index 7e5ff625..d0e5bdf9 100644 +--- a/Makefile ++++ b/Makefile +@@ -37,6 +37,18 @@ ifneq (,$(findstring unix,$(platform))) + endif + endif + ++# TrimUI Brick ++else ifeq ($(platform), my355) ++ TARGET := $(TARGET_NAME)_libretro.so ++ SHARED := -shared -Wl,--version-script=$(CORE_DIR)/libretro/link.T -Wl,--no-undefined ++ LDFLAGS += -lm -lpthread -ldl ++ LDFLAGS += -fPIC -flto ++ fpic := -fPIC ++ CFLAGS += -mtune=cortex-a55 -mcpu=cortex-a55 -march=armv8.2-a+crc+simd ++ CFLAGS += -fomit-frame-pointer -ffast-math -fPIC -flto ++ CFLAGS += -Ofast -flto=4 -fmerge-all-constants -fno-math-errno ++ CXXFLAGS += $(CFLAGS) ++ + # Raspberry Pi 4 + else ifneq (,$(findstring rpi4,$(platform))) + TARGET := $(TARGET_NAME)_libretro.so +diff --git a/sources/src/misc.c b/sources/src/misc.c +index a97b28bc..b328969d 100644 +--- a/sources/src/misc.c ++++ b/sources/src/misc.c +@@ -543,7 +543,7 @@ char *ua_fs_copy (char *dst, int maxlen, const TCHAR *src, int defchar) + char *ua_copy (char *dst, int maxlen, const char *src) + { + dst[0] = 0; +- strncpy (dst, src, maxlen); ++ strncpy (dst, src, maxlen & 0xffffffff); + return dst; + } + +@@ -555,7 +555,7 @@ TCHAR *au (const char *s) + TCHAR *au_copy (TCHAR *dst, int maxlen, const char *src) + { + dst[0] = 0; +- memcpy (dst, src, maxlen); ++ memcpy (dst, src, maxlen & 0xffffffff); + return dst; + } + diff --git a/workspace/my355/cores/patches/mednafen_pce_fast.patch b/workspace/my355/cores/patches/mednafen_pce_fast.patch new file mode 100755 index 000000000..6dc3b0bf6 --- /dev/null +++ b/workspace/my355/cores/patches/mednafen_pce_fast.patch @@ -0,0 +1,25 @@ +diff --git forkSrcPrefix/Makefile forkDstPrefix/Makefile +index 5b54403d915e46cb0df8f428355665fbe26e05b4..f72733d9689aa78795ce8b9d777b0ab9fcc5b65e 100644 +--- forkSrcPrefix/Makefile ++++ forkDstPrefix/Makefile +@@ -380,6 +380,20 @@ else ifeq ($(platform), miyoo) + CXXFLAGS += -std=c++11 + CFLAGS += -std=gnu11 + ++# MIYOO FLIP ++else ifeq ($(platform), my355) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CC = $(CROSS_COMPILE)gcc ++ CXX = $(CROSS_COMPILE)g++ ++ AR = $(CROSS_COMPILE)ar ++ fpic := -fPIC ++ SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T ++ LDFLAGS += -lrt ++ FLAGS += -mcpu=cortex-a55 -mtune=cortex-a55 ++ FLAGS += -fomit-frame-pointer -ffast-math -D_GNU_SOURCE ++ CXXFLAGS += -std=c++11 ++ CFLAGS += -std=gnu11 ++ + # Windows MSVC 2017 all architectures + else ifneq (,$(findstring windows_msvc2017,$(platform))) + diff --git a/workspace/my355/cores/patches/mednafen_supafaust.patch b/workspace/my355/cores/patches/mednafen_supafaust.patch new file mode 100755 index 000000000..c774879bb --- /dev/null +++ b/workspace/my355/cores/patches/mednafen_supafaust.patch @@ -0,0 +1,34 @@ +diff --git forkSrcPrefix/Makefile forkDstPrefix/Makefile +index f34a01587cda48cc28ebdfd7f00151b06ea88c42..6966d3c4802b200dea33bdbe8e96b2082a36d577 100644 +--- forkSrcPrefix/Makefile ++++ forkDstPrefix/Makefile +@@ -88,6 +88,29 @@ else ifeq ($(platform), classic_armv8_a35) + ARCH = arm + CFLAGS += -march=armv8-a + LDFLAGS += -static-libgcc -static-libstdc++ ++ ++# MIYOO FLIP ++else ifeq ($(platform), my355) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CC = $(CROSS_COMPILE)gcc ++ CXX = $(CROSS_COMPILE)g++ ++ AR = $(CROSS_COMPILE)ar ++ STRIP = $(CROSS_COMPILE)strip ++ NEED_BPP := 16 ++ fpic := -fPIC ++ SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T ++ CFLAGS += -mcpu=cortex-a55 -mtune=cortex-a55 ++ CFLAGS += -Ofast \ ++ -flto=4 -fwhole-program -fuse-linker-plugin \ ++ -fdata-sections -ffunction-sections -Wl,--gc-sections \ ++ -fno-stack-protector -fno-ident -fomit-frame-pointer \ ++ -falign-functions=1 -falign-jumps=1 -falign-loops=1 \ ++ -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \ ++ -fmerge-all-constants -fno-math-errno ++ CXXFLAGS += $(CFLAGS) ++ HAVE_NEON = 1 ++ ARCH = arm64 ++ + ####################################### + + else ifeq ($(platform), osx) diff --git a/workspace/my355/cores/patches/mednafen_vb.patch b/workspace/my355/cores/patches/mednafen_vb.patch new file mode 100755 index 000000000..4c98a98ff --- /dev/null +++ b/workspace/my355/cores/patches/mednafen_vb.patch @@ -0,0 +1,29 @@ +diff --git forkSrcPrefix/Makefile forkDstPrefix/Makefile +index c3d5d3b30d71a8f9ed332482fa2af1c21b02605d..5e710154e499ddd7b1ae699122c38753b0f4bb4c 100644 +--- forkSrcPrefix/Makefile ++++ forkDstPrefix/Makefile +@@ -217,6 +217,24 @@ else ifneq (,$(filter $(platform), ps3 psl1ght)) + endif + FLAGS += -D__PS3__ + ++# MIYOO FLIP ++else ifeq ($(platform), my355) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CC = $(CROSS_COMPILE)gcc ++ CXX = $(CROSS_COMPILE)g++ ++ AR = $(CROSS_COMPILE)ar ++ NEED_BPP := 16 ++ fpic := -fPIC ++ SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T ++ LDFLAGS += -lrt ++ CFLAGS += -fomit-frame-pointer -ffast-math -fPIC -flto ++ CFLAGS += -mcpu=cortex-a55 -mtune=cortex-a55 ++ CPPFLAGS += $(CFLAGS) ++ LDFLAGS += -flto ++ ifeq (,$(DEBUG)) ++ LDFLAGS += -s ++ endif ++ + # PSP + else ifeq ($(platform), psp1) + TARGET := $(TARGET_NAME)_libretro_$(platform).a diff --git a/workspace/my355/cores/patches/mgba.patch b/workspace/my355/cores/patches/mgba.patch new file mode 100755 index 000000000..31a55d194 --- /dev/null +++ b/workspace/my355/cores/patches/mgba.patch @@ -0,0 +1,31 @@ +diff --git forkSrcPrefix/Makefile.libretro forkDstPrefix/Makefile.libretro +index 108148f4579f4727146e5b8c1e05ef7382654208..35e6399147a4ef75947ecb2ad4a94f0820ef24d0 100644 +--- forkSrcPrefix/Makefile.libretro ++++ forkDstPrefix/Makefile.libretro +@@ -417,6 +417,26 @@ else ifeq ($(platform), miyoo) + CFLAGS += -fno-common -ftree-vectorize -funswitch-loops + DEFINES += -std=c99 + ++# MIYOO FLIP ++else ifeq ($(platform), my355) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CC = $(CROSS_COMPILE)gcc ++ CXX = $(CROSS_COMPILE)g++ ++ AR = $(CROSS_COMPILE)ar ++ SHARED := -shared -Wl,--version-script=link.T ++ fpic := -fPIC ++ PLATFORM_DEFINES += -D_GNU_SOURCE -DHAVE_STRTOF_L -DHAVE_LOCALE ++ CFLAGS += -fomit-frame-pointer -ffast-math ++ CFLAGS += -mcpu=cortex-a55 -mtune=cortex-a55 ++ CFLAGS += -fno-common -ftree-vectorize -funswitch-loops ++ HAVE_NEON = 1 ++ ARCH = arm64 ++ BUILTIN_GPU = neon ++ CPU_ARCH := arm ++ MMAP_JIT_CACHE = 1 ++ HAVE_DYNAREC = 1 ++ DEFINES += -std=c99 ++ + # Windows + else + TARGET := $(TARGET_NAME)_libretro.dll diff --git a/workspace/my355/cores/patches/pcsx_rearmed.patch b/workspace/my355/cores/patches/pcsx_rearmed.patch new file mode 100755 index 000000000..3fb34c2c2 --- /dev/null +++ b/workspace/my355/cores/patches/pcsx_rearmed.patch @@ -0,0 +1,30 @@ +diff --git forkSrcPrefix/Makefile.libretro forkDstPrefix/Makefile.libretro +index 7b9618e1ccfc63982be50b82fda498d75e307fdc..f314adcbea17f05f473e1cbafc8711ab8ea0c5f1 100644 +--- forkSrcPrefix/Makefile.libretro ++++ forkDstPrefix/Makefile.libretro +@@ -391,6 +391,25 @@ else ifeq ($(platform), rpi4_64) + fpic := -fPIC + CFLAGS += -march=armv8-a+crc+simd -mtune=cortex-a72 -ftree-vectorize + ++# MIYOO FLIP ++else ifeq ($(platform), my355) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CC = $(CROSS_COMPILE)gcc ++ CXX = $(CROSS_COMPILE)g++ ++ AR = $(CROSS_COMPILE)ar ++ CFLAGS += -mcpu=cortex-a55 -mtune=cortex-a55 -fomit-frame-pointer ++ CFLAGS += -ffast-math -fdata-sections -ffunction-sections -fsingle-precision-constant -flto -fPIC ++ LDFLAGS += -flto -fPIC ++ ifeq (,$(DEBUG)) ++ # LDFLAGS += -s ++ endif ++ CPU_ARCH := arm64 ++ OPTIMIZE := -Ofast -DNDEBUG=1 ++ HAVE_NEON = 1 ++ BUILTIN_GPU = neon ++ ARCH = arm64 ++ DYNAREC = ari64 ++ + # Classic Platforms #################### + # Platform affix = classic__<µARCH> + # Help at https://modmyclassic.com/comp diff --git a/workspace/my355/cores/patches/pet.patch b/workspace/my355/cores/patches/pet.patch new file mode 100644 index 000000000..c95f9e96a --- /dev/null +++ b/workspace/my355/cores/patches/pet.patch @@ -0,0 +1,21 @@ +diff --git a/Makefile b/Makefile +index 62cb321..e50aa6e 100644 +--- a/Makefile ++++ b/Makefile +@@ -380,6 +380,16 @@ else ifneq (,$(findstring armv,$(platform))) + endif + CFLAGS += -DARM -marm -DALIGN_DWORD -mthumb-interwork -falign-functions=16 -pipe -fstack-protector + ++# TrimUI Brick ++else ifeq ($(platform), my355) ++ TARGET := $(TARGET_NAME)_libretro.so ++ fpic := -fPIC ++ SHARED := -shared -Wl,--no-undefined ++ LDFLAGS += -shared -Wl,--version-script=$(CORE_DIR)/libretro/link.T ++ HAVE_NEON = 1 ++ CFLAGS += -DARM -DALIGN_DWORD -falign-functions=16 -pipe -fstack-protector ++ CFLAGS += -mtune=cortex-a55 -mcpu=cortex-a55 -march=armv8-a ++ + # Wincross64 + else ifeq ($(platform), wincross64) + AR = x86_64-w64-mingw32-ar diff --git a/workspace/my355/cores/patches/picodrive.patch b/workspace/my355/cores/patches/picodrive.patch new file mode 100755 index 000000000..364cbc5b8 --- /dev/null +++ b/workspace/my355/cores/patches/picodrive.patch @@ -0,0 +1,35 @@ +diff --git forkSrcPrefix/Makefile.libretro forkDstPrefix/Makefile.libretro +index 0d1dc08f81a11cef6b3b7238367b1ff27fcf1ead..1f87c76c3242023c4095f0c9087c52765d93c33c 100644 +--- forkSrcPrefix/Makefile.libretro ++++ forkDstPrefix/Makefile.libretro +@@ -497,6 +497,30 @@ else ifeq ($(platform), miyoo) + HAVE_ARMv6 = 0 + LOW_MEMORY = 1 + ++# MIYOO FLIP ++else ifeq ($(platform), my355) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CC = $(CROSS_COMPILE)gcc ++ CXX = $(CROSS_COMPILE)g++ ++ AR = $(CROSS_COMPILE)ar ++ SHARED := -shared -Wl,--no-undefined ++ DONT_COMPILE_IN_ZLIB = 1 ++ CFLAGS += -Ofast \ ++ -fdata-sections -ffunction-sections -Wl,--gc-sections \ ++ -fno-stack-protector -fno-ident -fomit-frame-pointer \ ++ -falign-functions=1 -falign-jumps=1 -falign-loops=1 \ ++ -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \ ++ -fmerge-all-constants -fno-math-errno ++ CFLAGS += -fPIC -flto ++ CFLAGS += -fomit-frame-pointer -ffast-math -D__GCW0__ ++ CFLAGS += -mcpu=cortex-a55 -mtune=cortex-a55 ++ LDFLAGS += -flto ++ HAVE_NEON = 1 ++ BUILTIN_GPU = neon ++ ifeq (,$(DEBUG)) ++ LDFLAGS += -s ++ endif ++ + # Windows MSVC 2017 all architectures + else ifneq (,$(findstring windows_msvc2017,$(platform))) + NO_GCC := 1 diff --git a/workspace/my355/cores/patches/plus4.patch b/workspace/my355/cores/patches/plus4.patch new file mode 100644 index 000000000..042b15e62 --- /dev/null +++ b/workspace/my355/cores/patches/plus4.patch @@ -0,0 +1,21 @@ +diff --git a/Makefile b/Makefile +index 62cb321..e50aa6e 100644 +--- a/Makefile ++++ b/Makefile +@@ -380,6 +380,16 @@ else ifneq (,$(findstring armv,$(platform))) + endif + CFLAGS += -DARM -marm -DALIGN_DWORD -mthumb-interwork -falign-functions=16 -pipe -fstack-protector + ++# TrimUI Brick ++else ifeq ($(platform), my355) ++ TARGET := $(TARGET_NAME)_libretro.so ++ fpic := -fPIC ++ SHARED := -shared -Wl,--no-undefined ++ LDFLAGS += -shared -Wl,--version-script=$(CORE_DIR)/libretro/link.T ++ HAVE_NEON = 1 ++ CFLAGS += -DARM -DALIGN_DWORD -falign-functions=16 -pipe -fstack-protector ++ CFLAGS += -mtune=cortex-a55 -mcpu=cortex-a55 -march=armv8.2-a ++ + # Wincross64 + else ifeq ($(platform), wincross64) + AR = x86_64-w64-mingw32-ar diff --git a/workspace/my355/cores/patches/pokemini.patch b/workspace/my355/cores/patches/pokemini.patch new file mode 100755 index 000000000..a07057791 --- /dev/null +++ b/workspace/my355/cores/patches/pokemini.patch @@ -0,0 +1,27 @@ +diff --git forkSrcPrefix/Makefile.libretro forkDstPrefix/Makefile.libretro +index ef2f9e7d1c6041bea8e2c8a61cdd363ed73a7482..ada8785f566af89cc77f5ab2dd9e670b0a998545 100644 +--- forkSrcPrefix/Makefile.libretro ++++ forkDstPrefix/Makefile.libretro +@@ -504,6 +504,22 @@ else ifeq ($(platform), retrofw) + CFLAGS += -ffast-math -fomit-frame-pointer -march=mips32 -mtune=mips32 -mhard-float + CFLAGS += -DDINGUX + ++# MIYOO FLIP ++else ifeq ($(platform), my355) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CC = $(CROSS_COMPILE)gcc ++ CXX = $(CROSS_COMPILE)g++ ++ AR = $(CROSS_COMPILE)ar ++ SHARED := -shared -Wl,--version-script=libretro/link.T -Wl,--no-undefined ++ fpic := -fPIC ++ CFLAGS += -DARM ++ CFLAGS += $(PTHREAD_FLAGS) ++ CFLAGS += -mcpu=cortex-a55 -mtune=cortex-a55 ++ CFLAGS += -ffast-math -fomit-frame-pointer ++ CFLAGS += -DDINGUX ++ HAVE_NEON = 1 ++ ARCH = arm64 ++ + else ifeq ($(platform), msvc) + OBJOUT = -Fo + diff --git a/workspace/my355/cores/patches/prboom.patch b/workspace/my355/cores/patches/prboom.patch new file mode 100644 index 000000000..7db38ee2a --- /dev/null +++ b/workspace/my355/cores/patches/prboom.patch @@ -0,0 +1,30 @@ +diff --git a/Makefile b/Makefile +index 3d068a5..7d14f14 100644 +--- a/Makefile ++++ b/Makefile +@@ -378,7 +378,24 @@ else ifeq ($(platform), miyoo) + SHARED := -shared -Wl,--version-script=libretro/link.T -Wl,-no-undefined + CFLAGS += -ffast-math -march=armv5te -mtune=arm926ej-s -fomit-frame-pointer + HAVE_LOW_MEMORY = 1 +- ++# target platform my355 trimUI brick ++else ifeq ($(platform), my355) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CC = $(CROSS_COMPILE)gcc ++ CXX = $(CROSS_COMPILE)g++ ++ AR = $(CROSS_COMPILE)ar ++ fpic := -fPIC ++ LDFLAGS += -s $(fpic) -shared -Wl,--version-script=libretro/link.T -Wl,-no-undefined ++ CFLAGS += -mtune=cortex-a55 -mcpu=cortex-a55 -march=armv8.2-a ++ CFLAGS += -fomit-frame-pointer -ffast-math -fPIC -flto ++ $(MYARCH) ++ CXXFLAGS += $(CFLAGS) ++ CPPFLAGS += $(CFLAGS) ++ ASFLAGS += $(CFLAGS) ++ HAVE_NEON = 1 ++ HAVE_LOW_MEMORY = 1 ++ CPU_ARCH := arm64 ++ ARM = 1 + # Windows MSVC 2003 Xbox 1 + else ifeq ($(platform), xbox1_msvc2003) + TARGET := $(TARGET_NAME)_libretro_xdk1.lib diff --git a/workspace/my355/cores/patches/race.patch b/workspace/my355/cores/patches/race.patch new file mode 100755 index 000000000..c3af51b4a --- /dev/null +++ b/workspace/my355/cores/patches/race.patch @@ -0,0 +1,23 @@ +diff --git forkSrcPrefix/Makefile forkDstPrefix/Makefile +index 792a6d82915c32edd3df6ceec541499f6ca25ac5..dc02b361d7db47e011b6d3addf89cfb31503575a 100644 +--- forkSrcPrefix/Makefile ++++ forkDstPrefix/Makefile +@@ -373,6 +373,18 @@ else ifeq ($(platform), miyoo) + CFLAGS += -fomit-frame-pointer -ffast-math -march=armv5te -mtune=arm926ej-s + CXXFLAGS += $(CFLAGS) + ++# MIYOO FLIP ++else ifeq ($(platform), my355) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CC = $(CROSS_COMPILE)gcc ++ CXX = $(CROSS_COMPILE)g++ ++ AR = $(CROSS_COMPILE)ar ++ fpic := -fPIC ++ SHARED := -shared -Wl,-version-script=$(LIBRETRO_DIR)/link.T ++ PLATFORM_DEFINES := -DCC_RESAMPLER -DCC_RESAMPLER_NO_HIGHPASS ++ CFLAGS += -fomit-frame-pointer -ffast-math -mcpu=cortex-a55 -mtune=cortex-a55 ++ CXXFLAGS += $(CFLAGS) ++ + # Windows MSVC 2010 x64 + else ifeq ($(platform), windows_msvc2010_x64) + CC = cl.exe diff --git a/workspace/my355/cores/patches/snes9x.patch b/workspace/my355/cores/patches/snes9x.patch new file mode 100644 index 000000000..ba586f973 --- /dev/null +++ b/workspace/my355/cores/patches/snes9x.patch @@ -0,0 +1,22 @@ +diff --git a/libretro/Makefile b/libretro/Makefile +index 466fa6b..ec40f1a +--- a/libretro/Makefile ++++ b/libretro/Makefile +@@ -82,6 +82,17 @@ ifneq (,$(findstring unix,$(platform))) + endif + endif + ++# my355 ++else ifneq (,$(findstring my355,$(platform))) ++ CC=$(CROSS_COMPILE)gcc ++ CXX=$(CROSS_COMPILE)g++ ++ CFLAGS += $(LTO) ++ CXXFLAGS += $(LTO) -O3 -Ofast -march=armv8.2-a+simd -mtune=cortex-a55 -ffast-math ++ LDFLAGS += $(LTO) -lstdc++ -flto ++ TARGET := $(TARGET_NAME)_libretro.so ++ fpic := -fPIC ++ LIBS += -lz ++ SHARED := -shared -Wl,--version-script=link.T -Wl,-z,defs + # ODROIDN2 + else ifneq (,$(findstring CortexA73_G12B,$(platform))) + TARGET := $(TARGET_NAME)_libretro.so diff --git a/workspace/my355/cores/patches/snes9x2005_plus.patch b/workspace/my355/cores/patches/snes9x2005_plus.patch new file mode 100755 index 000000000..977f1f68d --- /dev/null +++ b/workspace/my355/cores/patches/snes9x2005_plus.patch @@ -0,0 +1,36 @@ +diff --git forkSrcPrefix/Makefile forkDstPrefix/Makefile +index 07d5368a8e78a020813732239ec369d83e931ede..009f13b8e61c634de4cb83e97785a10b83b4322d 100644 +--- forkSrcPrefix/Makefile ++++ forkDstPrefix/Makefile +@@ -288,6 +288,31 @@ else ifeq ($(platform), miyoo) + FLAGS += -fomit-frame-pointer -ffast-math -march=armv5te -mtune=arm926ej-s + FLAGS += -DFAST_ALIGNED_LSB_WORD_ACCESS -fno-unroll-loops + ++# MIYOO FLIP ++else ifeq ($(platform), my355) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CC = $(CROSS_COMPILE)gcc ++ CXX = $(CROSS_COMPILE)g++ ++ AR = $(CROSS_COMPILE)ar ++ SHARED := -shared -Wl,--version-script=link.T ++ LIBM := ++ CFLAGS += -Ofast \ ++ -flto=4 -fwhole-program -fuse-linker-plugin \ ++ -fdata-sections -ffunction-sections -Wl,--gc-sections \ ++ -fno-stack-protector -fno-ident -fomit-frame-pointer \ ++ -falign-functions=1 -falign-jumps=1 -falign-loops=1 \ ++ -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \ ++ -fmerge-all-constants -fno-math-errno ++ CFLAGS += -fPIC ++ CFLAGS += -DLSB_FIRST -DFAST_ALIGNED_LSB_WORD_ACCESS -DRIGHTSHIFT_IS_SAR ++ CFLAGS += -std=c99 -fomit-frame-pointer -ffast-math ++ CFLAGS += -mcpu=cortex-a55 -mtune=cortex-a55 ++ LDFLAGS += -flto ++ OPTIMIZE += -Ofast -DNDEBUG=1 ++ ifeq (,$(DEBUG)) ++ LDFLAGS += -s ++ endif ++ + # (armv7 a7, hard point, neon based) ### + # NESC, SNESC, C64 mini + else ifeq ($(platform), classic_armv7_a7) diff --git a/workspace/my355/cores/patches/vic.patch b/workspace/my355/cores/patches/vic.patch new file mode 100644 index 000000000..042b15e62 --- /dev/null +++ b/workspace/my355/cores/patches/vic.patch @@ -0,0 +1,21 @@ +diff --git a/Makefile b/Makefile +index 62cb321..e50aa6e 100644 +--- a/Makefile ++++ b/Makefile +@@ -380,6 +380,16 @@ else ifneq (,$(findstring armv,$(platform))) + endif + CFLAGS += -DARM -marm -DALIGN_DWORD -mthumb-interwork -falign-functions=16 -pipe -fstack-protector + ++# TrimUI Brick ++else ifeq ($(platform), my355) ++ TARGET := $(TARGET_NAME)_libretro.so ++ fpic := -fPIC ++ SHARED := -shared -Wl,--no-undefined ++ LDFLAGS += -shared -Wl,--version-script=$(CORE_DIR)/libretro/link.T ++ HAVE_NEON = 1 ++ CFLAGS += -DARM -DALIGN_DWORD -falign-functions=16 -pipe -fstack-protector ++ CFLAGS += -mtune=cortex-a55 -mcpu=cortex-a55 -march=armv8.2-a ++ + # Wincross64 + else ifeq ($(platform), wincross64) + AR = x86_64-w64-mingw32-ar diff --git a/workspace/my355/init/init.sh b/workspace/my355/init/init.sh new file mode 100644 index 000000000..f90dac850 --- /dev/null +++ b/workspace/my355/init/init.sh @@ -0,0 +1,75 @@ +#!/bin/sh +# will be copied to /miyoo355/app/355/ during build + +set -x + +if [ -f /usr/miyoo/bin/runmiyoo-original.sh ]; then + echo "already installed" + exit 0 +fi + +DIR="$(cd "$(dirname "$0")" && pwd)" + +export PATH=/tmp/bin:$DIR/payload/bin:$PATH +export LD_LIBRARY_PATH=/tmp/lib:$DIR/payload/lib:$LD_LIBRARY_PATH + +LAST_CALL_TIME=0 +hide() { + # killall show.elf || true + touch /tmp/fbdisplay_exit +} +show() { + CURRENT_TIME=$(date +%s) + if [ $((CURRENT_TIME - LAST_CALL_TIME)) -lt 2 ]; then + DELAY=$((2 - (CURRENT_TIME - LAST_CALL_TIME))) + echo "delay for $DELAY seconds" + sleep $DELAY + fi + + hide + # show.elf $DIR/res/$1 300 & + /usr/bin/fbdisplay $DIR/res/$1 & + LAST_CALL_TIME=$(date +%s) +} + +show "prep-env.png" +echo "preparing environment" +cd "$DIR" +cp -r payload/* /tmp +cd /tmp + +show "extract-root.png" +echo "extracting rootfs" +dd if=/dev/mtd3ro of=old_rootfs.squashfs bs=131072 + +show "unpack-root.png" +echo "unpacking rootfs" +unsquashfs old_rootfs.squashfs + +show "inject-hook.png" +echo "swapping runmiyoo.sh" +mv squashfs-root/usr/miyoo/bin/runmiyoo.sh squashfs-root/usr/miyoo/bin/runmiyoo-original.sh +mv runmiyoo.sh squashfs-root/usr/miyoo/bin/ + +show "pack-root.png" +echo "packing updated rootfs" +mksquashfs squashfs-root new_rootfs.squashfs -comp gzip -b 131072 -noappend -exports -all-root -force-uid 0 -force-gid 0 + +# mount so reboot remains available +mkdir -p /tmp/rootfs +mount /tmp/new_rootfs.squashfs /tmp/rootfs +export PATH=/tmp/rootfs/bin:/tmp/rootfs/usr/bin:/tmp/rootfs/sbin:$PATH +export LD_LIBRARY_PATH=/tmp/rootfs/lib:/tmp/rootfs/usr/lib:$LD_LIBRARY_PATH + +show "flash-root.png" +echo "flashing updated rootfs" +flashcp new_rootfs.squashfs /dev/mtd3 && sync + +show "reboot.png" +echo "done, rebooting" +sleep 2 +reboot +while :; do + sleep 1 +done +exit diff --git a/workspace/my355/init/payload/runmiyoo.sh b/workspace/my355/init/payload/runmiyoo.sh new file mode 100644 index 000000000..4411bf742 --- /dev/null +++ b/workspace/my355/init/payload/runmiyoo.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +# becomes /usr/miyoo/bin/runmiyoo.sh on my355 + +#wait for sdcard mounted +mounted=`cat /proc/mounts | grep sdcard` +cnt=0 +while [ "$mounted" == "" ] && [ $cnt -lt 6 ] ; do + sleep 0.5 + cnt=`expr $cnt + 1` + mounted=`cat /proc/mounts | grep sdcard` +done + +UPDATER_PATH=/mnt/SDCARD/.tmp_update/updater +if [ -f "$UPDATER_PATH" ]; then + "$UPDATER_PATH" +else + /usr/miyoo/bin/runmiyoo-original.sh +fi diff --git a/workspace/my355/init/res/extract-root.png b/workspace/my355/init/res/extract-root.png new file mode 100644 index 000000000..c42410bfc Binary files /dev/null and b/workspace/my355/init/res/extract-root.png differ diff --git a/workspace/my355/init/res/flash-root.png b/workspace/my355/init/res/flash-root.png new file mode 100644 index 000000000..4747ad0f7 Binary files /dev/null and b/workspace/my355/init/res/flash-root.png differ diff --git a/workspace/my355/init/res/inject-hook.png b/workspace/my355/init/res/inject-hook.png new file mode 100644 index 000000000..521bacfba Binary files /dev/null and b/workspace/my355/init/res/inject-hook.png differ diff --git a/workspace/my355/init/res/pack-root.png b/workspace/my355/init/res/pack-root.png new file mode 100644 index 000000000..6c587775a Binary files /dev/null and b/workspace/my355/init/res/pack-root.png differ diff --git a/workspace/my355/init/res/prep-env.png b/workspace/my355/init/res/prep-env.png new file mode 100644 index 000000000..cd6663587 Binary files /dev/null and b/workspace/my355/init/res/prep-env.png differ diff --git a/workspace/my355/init/res/reboot.png b/workspace/my355/init/res/reboot.png new file mode 100644 index 000000000..4e08c80d2 Binary files /dev/null and b/workspace/my355/init/res/reboot.png differ diff --git a/workspace/my355/init/res/unpack-root.png b/workspace/my355/init/res/unpack-root.png new file mode 100644 index 000000000..0b563d576 Binary files /dev/null and b/workspace/my355/init/res/unpack-root.png differ diff --git a/workspace/my355/install/boot.sh b/workspace/my355/install/boot.sh new file mode 100644 index 000000000..96e714c3e --- /dev/null +++ b/workspace/my355/install/boot.sh @@ -0,0 +1,85 @@ +#!/bin/sh +# NOTE: becomes .tmp_update/my355.sh + +PLATFORM="my355" +SDCARD_PATH="/mnt/SDCARD" +UPDATE_PATH="$SDCARD_PATH/MinUI.zip" +PAKZ_PATH="$SDCARD_PATH/*.pakz" +SYSTEM_PATH="$SDCARD_PATH/.system" + +export LD_LIBRARY_PATH=/usr/miyoo/lib:$LD_LIBRARY_PATH +export PATH=/usr/miyoo/bin:$PATH + +touch /tmp/fbdisplay_exit +cat /dev/zero > /dev/fb0 + +# only show splash if either UPDATE_PATH or pakz files exist +SHOW_SPLASH="no" +if [ -f "$UPDATE_PATH" ]; then + SHOW_SPLASH="yes" +else + for pakz in $PAKZ_PATH; do + if [ -e "$pakz" ]; then + SHOW_SPLASH="yes" + break + fi + done +fi +if [ "$SHOW_SPLASH" = "yes" ] ; then + cd $(dirname "$0")/$PLATFORM + ./show2.elf --mode=daemon --image="logo.png" --text="Installing..." --logoheight=128 --progress=-1 & + #sleep 0.5 + #SHOW_PID=$! +fi + +CPU_PATH=/sys/devices/system/cpu/cpufreq/policy0/scaling_governor +echo performance > "$CPU_PATH" + +# generic NextUI package install +for pakz in $PAKZ_PATH; do + if [ ! -e "$pakz" ]; then continue; fi + echo "TEXT:Extracting $pakz" > /tmp/show2.fifo + cd $(dirname "$0")/$PLATFORM + + ./unzip -o -d "$SDCARD_PATH" "$pakz" # >> $pakz.txt + rm -f "$pakz" + + # run postinstall if present + if [ -f $SDCARD_PATH/post_install.sh ]; then + echo "TEXT:Installing $pakz" > /tmp/show2.fifo + $SDCARD_PATH/post_install.sh # > $pakz_post.txt + rm -f $SDCARD_PATH/post_install.sh + fi +done + +# install/update +if [ -f "$UPDATE_PATH" ]; then + cd $(dirname "$0")/$PLATFORM + if [ -d "$SYSTEM_PATH" ]; then + echo "TEXT:Updating NextUI" > /tmp/show2.fifo + else + echo "TEXT:Installing NextUI" > /tmp/show2.fifo + fi + + # clean replacement for core paths + rm -rf $SYSTEM_PATH/$PLATFORM/bin + rm -rf $SYSTEM_PATH/$PLATFORM/lib + rm -rf $SYSTEM_PATH/$PLATFORM/paks/MinUI.pak + + unzip -o "$UPDATE_PATH" -d "$SDCARD_PATH" # &> /mnt/SDCARD/unzip.txt + rm -f "$UPDATE_PATH" + + # the updated system finishes the install/update + if [ -f $SYSTEM_PATH/$PLATFORM/bin/install.sh ]; then + $SYSTEM_PATH/$PLATFORM/bin/install.sh # &> $SDCARD_PATH/log.txt + fi +fi + +#kill $SHOW_PID + +LAUNCH_PATH="$SYSTEM_PATH/$PLATFORM/paks/MinUI.pak/launch.sh" +if [ -f "$LAUNCH_PATH" ] ; then + "$LAUNCH_PATH" +fi + +poweroff # under no circumstances should stock be allowed to touch this card \ No newline at end of file diff --git a/workspace/my355/install/logo.png b/workspace/my355/install/logo.png new file mode 100644 index 000000000..d19816bb3 Binary files /dev/null and b/workspace/my355/install/logo.png differ diff --git a/workspace/my355/install/update.sh b/workspace/my355/install/update.sh new file mode 100644 index 000000000..a9e3c6672 --- /dev/null +++ b/workspace/my355/install/update.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +# NOTE: becomes .system/my355/bin/install.h + +exit 0 \ No newline at end of file diff --git a/workspace/my355/keymon/credits.txt b/workspace/my355/keymon/credits.txt new file mode 100755 index 000000000..e885e5dd1 --- /dev/null +++ b/workspace/my355/keymon/credits.txt @@ -0,0 +1,3 @@ +based on eggs custom keymon for Trimui: + https://www.dropbox.com/sh/5e9xwvp672vt8cr/AABUIdw1vLYp9h0waoCUqHPOa/source?dl=0&subfolder_nav_tracking=1 +modified to use libmsettings \ No newline at end of file diff --git a/workspace/my355/keymon/keymon.c b/workspace/my355/keymon/keymon.c new file mode 100755 index 000000000..affb4951d --- /dev/null +++ b/workspace/my355/keymon/keymon.c @@ -0,0 +1,207 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +// #include "defines.h" + +#define VOLUME_MIN 0 +#define VOLUME_MAX 20 +#define BRIGHTNESS_MIN 0 +#define BRIGHTNESS_MAX 10 + +// uses different codes from SDL +#define CODE_MENU 1 +#define CODE_PLUS 115 +#define CODE_MINUS 114 + +// for ev.value +#define RELEASED 0 +#define PRESSED 1 +#define REPEAT 2 + +int getInt(char* path) { + int i = 0; + FILE *file = fopen(path, "r"); + if (file!=NULL) { + fscanf(file, "%i", &i); + fclose(file); + } + return i; +} +void getFile(char* path, char* buffer, size_t buffer_size) { + FILE *file = fopen(path, "r"); + if (file) { + fseek(file, 0L, SEEK_END); + size_t size = ftell(file); + if (size>buffer_size-1) size = buffer_size - 1; + rewind(file); + fread(buffer, sizeof(char), size, file); + fclose(file); + buffer[size] = '\0'; + } +} +int exactMatch(char* str1, char* str2) { + int len1 = strlen(str1); + if (len1!=strlen(str2)) return 0; + return (strncmp(str1,str2,len1)==0); +} + +static int input_fd = 0; +static struct input_event ev; + +static pthread_t ports_pt; +#define JACK_STATE_PATH "/sys/class/gpio/gpio150/value" +#define HDMI_STATE_PATH "/sys/class/drm/card0-HDMI-A-1/status" + +static int JACK_enabled(void) { + return !getInt(JACK_STATE_PATH); +} +static int HDMI_enabled(void) { + char value[64]; + getFile(HDMI_STATE_PATH, value, 64); + return exactMatch(value, "connected\n"); +} + +static void* watchPorts(void *arg) { + int has_jack,had_jack; + had_jack = had_jack = JACK_enabled(); + SetJack(has_jack); + + int has_hdmi,had_hdmi; + has_hdmi = had_hdmi = HDMI_enabled(); + SetHDMI(has_hdmi); + + while(1) { + sleep(1); + + has_jack = JACK_enabled(); + if (had_jack!=has_jack) { + had_jack = has_jack; + SetJack(has_jack); + } + + has_hdmi = HDMI_enabled(); + if (had_hdmi!=has_hdmi) { + had_hdmi = has_hdmi; + SetHDMI(has_hdmi); + } + } + + return 0; +} + +int main (int argc, char *argv[]) { + InitSettings(); + pthread_create(&ports_pt, NULL, &watchPorts, NULL); + + input_fd = open("/dev/input/event0", O_RDONLY | O_NONBLOCK | O_CLOEXEC); + + uint32_t input; + uint32_t val; + uint32_t menu_pressed = 0; + + uint32_t up_pressed = 0; + uint32_t up_just_pressed = 0; + uint32_t up_repeat_at = 0; + + uint32_t down_pressed = 0; + uint32_t down_just_pressed = 0; + uint32_t down_repeat_at = 0; + + uint8_t ignore; + uint32_t then; + uint32_t now; + struct timeval tod; + + gettimeofday(&tod, NULL); + then = tod.tv_sec * 1000 + tod.tv_usec / 1000; // essential SDL_GetTicks() + ignore = 0; + + while (1) { + gettimeofday(&tod, NULL); + now = tod.tv_sec * 1000 + tod.tv_usec / 1000; + // TODO: check if if necessary + if (now-then>1000) ignore = 1; // ignore input that arrived during sleep + + while(read(input_fd, &ev, sizeof(ev))==sizeof(ev)) { + if (ignore) continue; + val = ev.value; + + if (( ev.type != EV_KEY ) || ( val > REPEAT )) continue; + // printf("code: %i (%i)\n", ev.code, val); fflush(stdout); + switch (ev.code) { + case CODE_MENU: + menu_pressed = val; + break; + break; + case CODE_PLUS: + up_pressed = up_just_pressed = val; + if (val) up_repeat_at = now + 300; + break; + case CODE_MINUS: + down_pressed = down_just_pressed = val; + if (val) down_repeat_at = now + 300; + break; + default: + break; + } + } + + if (ignore) { + menu_pressed = 0; + up_pressed = up_just_pressed = 0; + down_pressed = down_just_pressed = 0; + up_repeat_at = 0; + down_repeat_at = 0; + } + + if (up_just_pressed || (up_pressed && now>=up_repeat_at)) { + if (menu_pressed) { + // printf("brightness up\n"); fflush(stdout); + val = GetBrightness(); + if (val=down_repeat_at)) { + if (menu_pressed) { + // printf("brightness down\n"); fflush(stdout); + val = GetBrightness(); + if (val>BRIGHTNESS_MIN) SetBrightness(--val); + } + else { + // printf("volume down\n"); fflush(stdout); + val = GetVolume(); + if (val>VOLUME_MIN) SetVolume(--val); + } + + if (down_just_pressed) down_just_pressed = 0; + else down_repeat_at += 100; + } + + then = now; + ignore = 0; + + usleep(16666); // 60fps + } +} diff --git a/workspace/my355/keymon/makefile b/workspace/my355/keymon/makefile new file mode 100755 index 000000000..2a4d458b9 --- /dev/null +++ b/workspace/my355/keymon/makefile @@ -0,0 +1,19 @@ +#keymon + +ifeq (,$(CROSS_COMPILE)) +$(error missing CROSS_COMPILE for this toolchain) +endif + +include ../../my355/platform/makefile.env + +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)\" +LDFLAGS += -lmsettings + +all: + $(CC) $(TARGET).c -o $(TARGET).elf $(CFLAGS) $(LDFLAGS) +clean: + rm -rf $(TARGET).elf diff --git a/workspace/my355/libmsettings/makefile b/workspace/my355/libmsettings/makefile new file mode 100644 index 000000000..06b41044e --- /dev/null +++ b/workspace/my355/libmsettings/makefile @@ -0,0 +1,32 @@ +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 = -ltinyalsa -ldl -lrt -s + +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/my355/libmsettings/msettings.c b/workspace/my355/libmsettings/msettings.c new file mode 100644 index 000000000..3ff22c0b8 --- /dev/null +++ b/workspace/my355/libmsettings/msettings.c @@ -0,0 +1,743 @@ +// my355 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "msettings.h" + +/////////////////////////////////////// + +typedef struct SettingsV1 { + 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; + int hdmi; + int audiosink; // was bluetooth true/false before +} SettingsV1; + +// When incrementing SETTINGS_VERSION, update the Settings typedef and add +// backwards compatibility to InitSettings! +#define SETTINGS_VERSION 1 +typedef SettingsV1 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, + .jack = 0, + .hdmi = 0, + .audiosink = AUDIO_SINK_DEFAULT, +}; +static Settings* settings; + +#define SHM_KEY "/SharedSettings" +static char SettingsPath[256]; +static int shm_fd = -1; +static int is_host = 0; +static int shm_size = sizeof(Settings); + +int scaleBrightness(int); +int scaleColortemp(int); +int scaleContrast(int); +int scaleSaturation(int); +int scaleExposure(int); +int scaleVolume(int); + +void disableDpad(int); +void emulateJoystick(int); +void turboA(int); +void turboB(int); +void turboX(int); +void turboY(int); +void turboL1(int); +void turboL2(int); +void turboR1(int); +void turboR2(int); + +int getInt(char* path) { + int i = 0; + FILE *file = fopen(path, "r"); + if (file!=NULL) { + fscanf(file, "%i", &i); + fclose(file); + } + return i; +} +void getFile(char* path, char* buffer, size_t buffer_size) { + FILE *file = fopen(path, "r"); + if (file) { + fseek(file, 0L, SEEK_END); + size_t size = ftell(file); + if (size>buffer_size-1) size = buffer_size - 1; + rewind(file); + fread(buffer, sizeof(char), size, file); + fclose(file); + buffer[size] = '\0'; + } +} +void putFile(char* path, char* contents) { + FILE* file = fopen(path, "w"); + if (file) { + fputs(contents, file); + fclose(file); + } +} +void putInt(char* path, int value) { + char buffer[8]; + sprintf(buffer, "%d", value); + putFile(path, buffer); +} + +void touch(char* path) { + close(open(path, O_RDWR|O_CREAT, 0777)); +} + +int exactMatch(char* str1, char* str2) { + if (!str1 || !str2) return 0; // NULL isn't safe here + int len1 = strlen(str1); + if (len1!=strlen(str2)) return 0; + return (strncmp(str1,str2,len1)==0); +} + +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; +} + +#define JACK_STATE_PATH "/sys/class/gpio/gpio150/value" +#define HDMI_STATE_PATH "/sys/class/drm/card0-HDMI-A-1/status" + +static int JACK_enabled(void) { + return !getInt(JACK_STATE_PATH); +} +static int HDMI_enabled(void) { + char value[64]; + getFile(HDMI_STATE_PATH, value, 64); + return exactMatch(value, "connected\n"); +} + +void InitSettings(void) { + sprintf(SettingsPath, "%s/msettings.bin", getenv("USERDATA_PATH")); + + shm_fd = shm_open(SHM_KEY, O_RDWR | O_CREAT | O_EXCL, 0644); // see if it exists + if (shm_fd==-1 && errno==EEXIST) { // already exists + puts("Settings client"); + shm_fd = shm_open(SHM_KEY, O_RDWR, 0644); + settings = mmap(NULL, shm_size, PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, 0); + } + else { // host + puts("Settings host"); // should always be keymon + is_host = 1; + // we created it so set initial size and populate + ftruncate(shm_fd, shm_size); + settings = mmap(NULL, shm_size, PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, 0); + + // peek the first int from fd, it's the version + int version = peekVersion(SettingsPath); + if(version > 0) { + int fd = open(SettingsPath, O_RDONLY); + if (fd>=0) { + if (version == SETTINGS_VERSION) { + read(fd, settings, shm_size); + } + else { + // initialize with defaults + memcpy(settings, &DefaultSettings, shm_size); + + // overwrite with migrated data + if(version==42) { + // do migration (TODO when needed) + } + else { + printf("Found unsupported settings version: %i.\n", version); + } + } + + close(fd); + } + else { + // load defaults + memcpy(settings, &DefaultSettings, shm_size); + } + } + else { + // load defaults + memcpy(settings, &DefaultSettings, shm_size); + } + + // these shouldn't be persisted + // settings->jack = 0; + // settings->hdmi = 0; + } + + int jack = JACK_enabled(); + int hdmi = HDMI_enabled(); + printf("brightness: %i (hdmi: %i)\nspeaker: %i (jack: %i)\n", settings->brightness, hdmi, settings->speaker, jack); fflush(stdout); + + // // both of these set volume + SetJack(jack); + SetHDMI(hdmi); + + char cmd[256]; + sprintf(cmd, "amixer sset 'Playback Path' '%s' > /dev/null 2>&1", GetJack() ? "HP" : "SPK"); + system(cmd); + + SetVolume(GetVolume()); + SetBrightness(GetBrightness()); + // system("echo $(< " BRIGHTNESS_PATH ")"); +} +int InitializedSettings(void) { + return (settings != NULL); +} +void QuitSettings(void) { + munmap(settings, shm_size); + if (is_host) shm_unlink(SHM_KEY); +} +static inline void SaveSettings(void) { + int fd = open(SettingsPath, O_CREAT|O_WRONLY, 0644); + if (fd>=0) { + write(fd, settings, shm_size); + close(fd); + sync(); + } +} + +///////// Getters exposed in public API + +int GetBrightness(void) { // 0-10 + return settings->brightness; +} +int GetColortemp(void) { // 0-10 + return settings->colortemperature; +} +int GetVolume(void) { // 0-20 + if(settings->jack || settings->audiosink != AUDIO_SINK_DEFAULT) + return settings->headphones; + + return settings->speaker; +} +// monitored and set by thread in keymon +int GetJack(void) { + return settings->jack; +} +// monitored and set by thread in audiomon +int GetAudioSink(void) { + return settings->audiosink; +} + +int GetHDMI(void) { + // printf("GetHDMI() %i\n", settings->hdmi); fflush(stdout); + return settings->hdmi; +}; + +int GetMute(void) { + return 0; +} + +int GetContrast(void) +{ + return settings->contrast; +} +int GetSaturation(void) +{ + return settings->saturation; +} +int GetExposure(void) +{ + return settings->exposure; +} +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; +} +int GetMuteDisablesDpad(void) +{ + return 0; +} +int GetMuteEmulatesJoystick(void) +{ + return 0; +} +int GetMuteTurboA(void) +{ + return 0; +} +int GetMuteTurboB(void) +{ + return 0; +} +int GetMuteTurboX(void) +{ + return 0; +} +int GetMuteTurboY(void) +{ + return 0; +} +int GetMuteTurboL1(void) +{ + return 0; +} +int GetMuteTurboL2(void) +{ + return 0; +} +int GetMuteTurboR1(void) +{ + return 0; +} +int GetMuteTurboR2(void) +{ + return 0; +} + +///////// Setters exposed in public API + +void SetBrightness(int value) { + SetRawBrightness(scaleBrightness(value)); + settings->brightness = value; + SaveSettings(); +} +void SetColortemp(int value) { + SetRawColortemp(scaleColortemp(value)); + settings->colortemperature = value; + SaveSettings(); +} +void SetVolume(int value) { // 0-20 + if (settings->jack || settings->audiosink != AUDIO_SINK_DEFAULT) + settings->headphones = value; + else + settings->speaker = value; + + SetRawVolume(scaleVolume(value)); + SaveSettings(); +} +// monitored and set by thread in keymon +void SetJack(int value) { + printf("SetJack(%i)\n", value); fflush(stdout); + + settings->jack = value; + SetVolume(GetVolume()); +} +// monitored and set by thread in audiomon +void SetAudioSink(int value) { + printf("SetAudioSink(%i)\n", value); fflush(stdout); + + settings->audiosink = value; + SetVolume(GetVolume()); +} + +void SetHDMI(int value){ + // printf("SetHDMI(%i)\n", value); fflush(stdout); + settings->hdmi = value; + if (value) SetRawVolume(100); // max + else SetVolume(GetVolume()); // restore +}; + +void SetMute(int value){} + +void SetContrast(int value) +{ + SetRawContrast(scaleContrast(value)); + settings->contrast = value; + SaveSettings(); +} +void SetSaturation(int value) +{ + SetRawSaturation(scaleSaturation(value)); + settings->saturation = value; + SaveSettings(); +} +void SetExposure(int value) +{ + SetRawExposure(scaleExposure(value)); + settings->exposure = value; + SaveSettings(); +} + +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 SetMuteDisablesDpad(int value) +{ +} +void SetMuteEmulatesJoystick(int value) +{ +} + +void SetMuteTurboA(int value) +{ +} + +void SetMuteTurboB(int value) +{ +} + +void SetMuteTurboX(int value) +{ +} + +void SetMuteTurboY(int value) +{ +} + +void SetMuteTurboL1(int value) +{ +} + +void SetMuteTurboL2(int value) +{ +} + +void SetMuteTurboR1(int value) +{ +} + +void SetMuteTurboR2(int value) +{ +} + +///////// Platform specific scaling + +int scaleVolume(int value) { + return value * 5; // scale 0-20 to 0-100 +} + +int scaleBrightness(int value) { + int raw; + switch (value) { + // TODO :revisit + case 0: raw = 1; break; // + case 1: raw = 6; break; // + case 2: raw = 10; break; // + case 3: raw = 16; break; // + case 4: raw = 32; break; // + case 5: raw = 48; break; // + case 6: raw = 64; break; // + case 7: raw = 96; break; // + case 8: raw = 128; break; // + case 9: raw = 192; break; // + case 10: raw = 255; break; // + } + return raw; +} +int scaleColortemp(int value) { + int raw; + + switch (value) { + case 0: raw=-200; break; // 8 + case 1: raw=-190; break; // 8 + case 2: raw=-180; break; // 16 + case 3: raw=-170; break; // 16 + case 4: raw=-160; break; // 24 + case 5: raw=-150; break; // 24 + case 6: raw=-140; break; // 32 + case 7: raw=-130; break; // 32 + case 8: raw=-120; break; // 32 + case 9: raw=-110; break; // 64 + case 10: raw=-100; break; // 0 + case 11: raw=-90; break; // 8 + case 12: raw=-80; break; // 8 + case 13: raw=-70; break; // 16 + case 14: raw=-60; break; // 16 + case 15: raw=-50; break; // 24 + case 16: raw=-40; break; // 24 + case 17: raw=-30; break; // 32 + case 18: raw=-20; break; // 32 + case 19: raw=-10; break; // 32 + case 20: raw=0; break; // 64 + case 21: raw=10; break; // 0 + case 22: raw=20; break; // 8 + case 23: raw=30; break; // 8 + case 24: raw=40; break; // 16 + case 25: raw=50; break; // 16 + case 26: raw=60; break; // 24 + case 27: raw=70; break; // 24 + case 28: raw=80; break; // 32 + case 29: raw=90; break; // 32 + case 30: raw=100; break; // 32 + case 31: raw=110; break; // 64 + case 32: raw=120; break; // 0 + case 33: raw=130; break; // 8 + case 34: raw=140; break; // 8 + case 35: raw=150; break; // 16 + case 36: raw=160; break; // 16 + case 37: raw=170; break; // 24 + case 38: raw=180; break; // 24 + case 39: raw=190; break; // 32 + case 40: raw=200; break; // 32 + } + return raw; +} +int scaleContrast(int value) { + int raw; + + switch (value) { + // dont offer -5/ raw 0, looks like it might turn off the display completely? + case -4: raw=10; break; + case -3: raw=20; break; + case -2: raw=30; break; + case -1: raw=40; break; + case 0: raw=50; break; + case 1: raw=60; break; + case 2: raw=70; break; + case 3: raw=80; break; + case 4: raw=90; break; + case 5: raw=100; break; + } + return raw; +} +int scaleSaturation(int value) { + int raw; + + switch (value) { + case -5: raw=0; break; + case -4: raw=10; break; + case -3: raw=20; break; + case -2: raw=30; break; + case -1: raw=40; break; + case 0: raw=50; break; + case 1: raw=60; break; + case 2: raw=70; break; + case 3: raw=80; break; + case 4: raw=90; break; + case 5: raw=100; break; + } + return raw; +} +int scaleExposure(int value) { + int raw; + + switch (value) { + // stock OS also avoids setting anything lower, so we do the same here. + case -4: raw=10; break; + case -3: raw=20; break; + case -2: raw=30; break; + case -1: raw=40; break; + case 0: raw=50; break; + case 1: raw=60; break; + case 2: raw=70; break; + case 3: raw=80; break; + case 4: raw=90; break; + case 5: raw=100; break; + } + return raw; +} + +///////// Platform specific, unscaled accessors + +#define DISP_LCD_SET_BRIGHTNESS 0x102 +void SetRawBrightness(int val) { // 0 - 255 + printf("SetRawBrightness(%i)\n", val); fflush(stdout); + putInt("/sys/class/backlight/backlight/brightness", val); +} +void SetRawColortemp(int val) { // 0 - 255 + printf("SetRawColortemp(%i)\n", val); fflush(stdout); + + FILE *fd = fopen("/sys/class/disp/disp/attr/color_temperature", "w"); + if (fd) { + fprintf(fd, "%i", val); + fclose(fd); + } +} + +// Find the first A2DP playback volume control via amixer +static int get_a2dp_simple_control_name(char *buf, size_t buflen) { + FILE *fp = popen("amixer scontrols", "r"); + if (!fp) return 0; + + char line[256]; + while (fgets(line, sizeof(line), fp)) { + char *start = strchr(line, '\''); + char *end = strrchr(line, '\''); + if (start && end && end > start) { + size_t len = end - start - 1; + if (len < buflen) { + strncpy(buf, start + 1, len); + buf[len] = '\0'; + if (strstr(buf, "A2DP")) { // first A2DP simple control + pclose(fp); + char esc_buf[128]; + char *src = buf; + char *dst = esc_buf; + while(*src && (dst - esc_buf) < (sizeof(esc_buf) - 4)) { + if(*src == '\"') { + *dst++ = '\\'; + *dst++ = '\"'; + } else { + *dst++ = *src; + } + src++; + } + *dst = '\0'; + strncpy(buf, esc_buf, buflen); + buf[buflen - 1] = '\0'; + return 1; + } + } + } + } + + pclose(fp); + return 0; +} + +void SetRawVolume(int val) { // 0-100 + + if (GetAudioSink() == AUDIO_SINK_BLUETOOTH) { + // bluealsa is a mixer plugin, not exposed as a separate card + char ctl_name[128] = {0}; + if (get_a2dp_simple_control_name(ctl_name, sizeof(ctl_name))) { + char cmd[256]; + // Update volume on the device + snprintf(cmd, sizeof(cmd), "amixer sset \"%s\" -M %d%% &> /dev/null", ctl_name, val); + system(cmd); + //printf("Set '%s' to %d%%\n", ctl_name, val); fflush(stdout); + } + } + else if (GetAudioSink() == AUDIO_SINK_USBDAC) { + // USB DAC path: use card 1 + struct mixer *mixer = mixer_open(1); + if (!mixer) { + printf("Failed to open mixer\n"); fflush(stdout); + return; + } + + const unsigned int num_controls = mixer_get_num_ctls(mixer); + for (unsigned int i = 0; i < num_controls; i++) { + struct mixer_ctl *ctl = mixer_get_ctl(mixer, i); + const char *name = mixer_ctl_get_name(ctl); + if (!name) continue; + + if (strstr(name, "PCM") && (strstr(name, "Volume") || strstr(name, "volume"))) { + if (mixer_ctl_get_type(ctl) == MIXER_CTL_TYPE_INT) { + int min = mixer_ctl_get_range_min(ctl); + int max = mixer_ctl_get_range_max(ctl); + int volume = min + (val * (max - min)) / 100; + unsigned int num_values = mixer_ctl_get_num_values(ctl); + for (unsigned int i = 0; i < num_values; i++) + mixer_ctl_set_value(ctl, i, volume); + } + break; + } + } + mixer_close(mixer); + } + else { + system("amixer sset 'SPK' 1% > /dev/null 2>&1"); // ensure there is always a change + if (settings->jack) { + system("amixer sset 'Playback Path' 'HP' > /dev/null 2>&1"); + puts("headphones"); fflush(stdout); + } + else if (val==0) { + system("amixer sset 'Playback Path' 'OFF' > /dev/null 2>&1"); // mute speaker (not headphone as that produces white noise) + puts("mute"); fflush(stdout); + } + else { + system("amixer sset 'Playback Path' 'SPK' > /dev/null 2>&1"); + puts("speaker"); fflush(stdout); + } + + char cmd[256]; + sprintf(cmd, "amixer sset 'SPK' %i%% > /dev/null 2>&1", val); + puts(cmd); fflush(stdout); + system(cmd); + } +} + +void SetRawContrast(int val){ + printf("SetRawContrast(%i)\n", val); fflush(stdout); + + FILE *fd = fopen("/sys/class/disp/disp/attr/enhance_contrast", "w"); + if (fd) { + fprintf(fd, "%i", val); + fclose(fd); + } +} +void SetRawSaturation(int val){ + printf("SetRawSaturation(%i)\n", val); fflush(stdout); + + FILE *fd = fopen("/sys/class/disp/disp/attr/enhance_saturation", "w"); + if (fd) { + fprintf(fd, "%i", val); + fclose(fd); + } +} +void SetRawExposure(int val){ + printf("SetRawExposure(%i)\n", val); fflush(stdout); + + FILE *fd = fopen("/sys/class/disp/disp/attr/enhance_bright", "w"); + if (fd) { + fprintf(fd, "%i", val); + fclose(fd); + } +} diff --git a/workspace/my355/libmsettings/msettings.h b/workspace/my355/libmsettings/msettings.h new file mode 100644 index 000000000..5a03981e3 --- /dev/null +++ b/workspace/my355/libmsettings/msettings.h @@ -0,0 +1,99 @@ +#ifndef __msettings_h__ +#define __msettings_h__ + +#define SETTINGS_DEFAULT_BRIGHTNESS 2 +#define SETTINGS_DEFAULT_COLORTEMP 20 +#define SETTINGS_DEFAULT_CONTRAST 0 +#define SETTINGS_DEFAULT_SATURATION 0 +#define SETTINGS_DEFAULT_EXPOSURE 0 +#define SETTINGS_DEFAULT_VOLUME 8 +#define SETTINGS_DEFAULT_HEADPHONE_VOLUME 4 +#define SETTINGS_DEFAULT_FAN_SPEED 0 + +#define SETTINGS_DEFAULT_MUTE_NO_CHANGE -69 + +void InitSettings(void); +void QuitSettings(void); +int InitializedSettings(void); + +int GetBrightness(void); +int GetColortemp(void); +int GetContrast(void); +int GetSaturation(void); +int GetExposure(void); +int GetVolume(void); + +void SetRawBrightness(int value); // 0-255 +void SetRawColortemp(int value); // 0-255 +void SetRawContrast(int value); // 0-100 +void SetRawSaturation(int value); // 0-100 +void SetRawExposure(int value); // 0-100 +void SetRawVolume(int value); // 0-100 + +void SetBrightness(int value); // 0-10 +void SetColortemp(int value); // 0-40 +void SetContrast(int value); // -4-5 +void SetSaturation(int value); // -5-5 +void SetExposure(int value); // -4-5 +void SetVolume(int value); // 0-20 + +int GetJack(void); +void SetJack(int value); // 0-1 + +#define AUDIO_SINK_DEFAULT 0 // use system default, usually speaker (or jack if plugged in) +#define AUDIO_SINK_BLUETOOTH 1 // software control via bluealsa, not a separate card +#define AUDIO_SINK_USBDAC 2 // assumes being exposed as card 1 to alsa +int GetAudioSink(void); +void SetAudioSink(int value); + +int GetHDMI(void); +void SetHDMI(int value); // 0-1 + +int GetMute(void); +void SetMute(int value); // 0-1 + +// unused +inline int GetFanSpeed(void) { + return 0; +} +inline void SetFanSpeed(int value) { + // do nothing +} + +// custom mute mode persistence layer + +int GetMutedBrightness(void); +int GetMutedColortemp(void); +int GetMutedContrast(void); +int GetMutedSaturation(void); +int GetMutedExposure(void); +int GetMutedVolume(void); +int GetMuteDisablesDpad(void); +int GetMuteEmulatesJoystick(void); +int GetMuteTurboA(void); +int GetMuteTurboB(void); +int GetMuteTurboX(void); +int GetMuteTurboY(void); +int GetMuteTurboL1(void); +int GetMuteTurboL2(void); +int GetMuteTurboR1(void); +int GetMuteTurboR2(void); + +void SetMutedBrightness(int); +void SetMutedColortemp(int); +void SetMutedContrast(int); +void SetMutedSaturation(int); +void SetMutedExposure(int); +void SetMutedVolume(int); +void SetMuteDisablesDpad(int); +void SetMuteEmulatesJoystick(int); +void SetMuteTurboA(int); +void SetMuteTurboB(int); +void SetMuteTurboX(int); +void SetMuteTurboY(int); +void SetMuteTurboL1(int); +void SetMuteTurboL2(int); +void SetMuteTurboR1(int); +void SetMuteTurboR2(int); + +#endif // __msettings_h__ diff --git a/workspace/my355/makefile b/workspace/my355/makefile new file mode 100755 index 000000000..2cac9af1f --- /dev/null +++ b/workspace/my355/makefile @@ -0,0 +1,43 @@ +########################################################### + +ifeq (,$(PLATFORM)) +PLATFORM=$(UNION_PLATFORM) +endif + +ifeq (,$(PLATFORM)) +$(error please specify PLATFORM, eg. PLATFORM=rgb30 make) +endif + +########################################################### + +REQUIRES_EVTEST=other/evtest +REQUIRES_MKBOOTIMG=other/mkbootimg +REQUIRES_RSCEGO=other/rsce-go +REQUIRES_FILEMGR=other/NextCommander + +all: readmes + cd other/squashfs && make + +early: $(REQUIRES_EVTEST) $(REQUIRES_MKBOOTIMG) $(REQUIRES_RSCEGO) $(REQUIRES_COMMANDER) + mkdir -p other + cd $(REQUIRES_FILEMGR) && make -j + cd $(REQUIRES_EVTEST) && $(CROSS_COMPILE)gcc -o evtest evtest.c + cd $(REQUIRES_MKBOOTIMG) && make + cd $(REQUIRES_RSCEGO) && go build -o rsce_tool + +clean: + cd $(REQUIRES_FILEMGR) && make clean + +########################################################### + +$(REQUIRES_FILEMGR): + git clone --depth 1 https://github.com/LoveRetro/NextCommander.git $(REQUIRES_FILEMGR) +$(REQUIRES_EVTEST): + git clone --depth 1 https://github.com/freedesktop-unofficial-mirror/evtest.git $(REQUIRES_EVTEST) +$(REQUIRES_MKBOOTIMG): + git clone --depth 1 https://github.com/LoveRetro/mkbootimg $(REQUIRES_MKBOOTIMG) +$(REQUIRES_RSCEGO): + git clone --depth 1 https://github.com/Evsio0n/rsce-go $(REQUIRES_RSCEGO) + cd $(REQUIRES_RSCEGO) && go mod tidy -e && go mod download + +include ../all/readmes/makefile diff --git a/workspace/my355/other/squashfs/makefile b/workspace/my355/other/squashfs/makefile new file mode 100755 index 000000000..fdfdbb130 --- /dev/null +++ b/workspace/my355/other/squashfs/makefile @@ -0,0 +1,28 @@ +########################################################### + +ifeq (,$(PLATFORM)) +PLATFORM=$(UNION_PLATFORM) +endif + +ifeq (,$(PLATFORM)) + $(error please specify PLATFORM, eg. PLATFORM=trimui make) +endif + +ifeq (,$(CROSS_COMPILE)) + $(error missing CROSS_COMPILE for this toolchain) +endif + +########################################################### + +all: + mkdir -p output + mkdir -p output/bin + mkdir -p output/lib + cp $(PREFIX)/bin/*squashfs output/bin + cp $(PREFIX)/lib/liblzma.so.5.8.2 output/lib + cp $(PREFIX)/lib/liblzo2.so.2.0.0 output/lib + cp $(PREFIX)/lib/liblz4.so.1.10.0 output/lib + cp $(PREFIX)/lib/libzstd.so.1.6.0 output/lib + +clean: + rm -rf output \ No newline at end of file diff --git a/workspace/my355/platform/makefile.copy b/workspace/my355/platform/makefile.copy new file mode 100755 index 000000000..16bc4511f --- /dev/null +++ b/workspace/my355/platform/makefile.copy @@ -0,0 +1,11 @@ +$(PLATFORM): + # installer + cp ./workspace/$@/install/boot.sh ./build/BOOT/common/$@.sh + cp ./workspace/$@/install/update.sh ./build/SYSTEM/$@/bin/install.sh + mkdir -p ./build/BOOT/common/$@/ + cp ./workspace/$@/install/*.png ./build/BOOT/common/$@/ + cp ./workspace/all/show2/build/$@/show2.elf ./build/BOOT/common/$@/ + + # extras + # cp ./workspace/$@/other/NextCommander/output/NextCommander ./build/EXTRAS/Tools/$@/Files.pak/ + cp -r ./workspace/$@/other/NextCommander/res ./build/EXTRAS/Tools/$@/Files.pak/ diff --git a/workspace/my355/platform/makefile.env b/workspace/my355/platform/makefile.env new file mode 100755 index 000000000..7adf7b644 --- /dev/null +++ b/workspace/my355/platform/makefile.env @@ -0,0 +1,27 @@ +# my355 +ARCH = -O3 -Ofast -fomit-frame-pointer +# -mtune/-march/-mpcu +# "When porting from x86 to Arm, you should replace any occurrences of -march +# with -mcpu and remove any instances of -mtune. +# This will have the desired effect of simultaneously tuning for the target +# architecture and microarchitecture." +# https://developer.arm.com/community/arm-community-blogs/b/tools-software-ides-blog/posts/compiler-flags-across-architectures-march-mtune-and-mcpu +CFLAGS = -mcpu=cortex-a55 -flto +SDL = SDL2 +GL = GLES +# legacy linux paths +CFLAGS += -I$(PREFIX)/include -I$(PREFIX_LOCAL)/include +LDFLAGS = -L$(PREFIX)/lib -L$(PREFIX_LOCAL)/lib +# multiarch support +CFLAGS += -I$(PREFIX)/include/$(CROSS_TRIPLE) +LDFLAGS += -L$(PREFIX)/lib/$(CROSS_TRIPLE) +# pkg-config +CFLAGS += $$(pkg-config --cflags sdl2 glesv2) +LDFLAGS += $$(pkg-config --libs sdl2 glesv2) +# not handled by pkg-config +CFLAGS += -DUSE_$(SDL) -DUSE_$(GL) -DGL_GLEXT_PROTOTYPES +LDFLAGS += -l$(SDL)_image -l$(SDL)_ttf -lpthread -ldl -lm -lz + +# TODO: this shouldnt be necessary. +# move resampling code out of api.c +LDFLAGS += -lsamplerate \ No newline at end of file diff --git a/workspace/my355/platform/platform.c b/workspace/my355/platform/platform.c new file mode 100755 index 000000000..cb16b0983 --- /dev/null +++ b/workspace/my355/platform/platform.c @@ -0,0 +1,659 @@ +// my355 +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include "defines.h" +#include "platform.h" +#include "api.h" +#include "utils.h" + +#include "scaler.h" +#include +#include + +#include + +/////////////////////////////// + +int on_hdmi = 0; + +#define HDMI_STATE_PATH "/sys/class/drm/card0-HDMI-A-1/status" + +static int HDMI_enabled(void) { + char value[64]; + getFile(HDMI_STATE_PATH, value, 64); + return exactMatch(value, "connected\n"); +} + +#define LID_PATH "/sys/devices/platform/hall-mh248/hallvalue" // 1 open, 0 closed +void PLAT_initLid(void) { + lid.has_lid = exists(LID_PATH); +} +int PLAT_lidChanged(int* state) { + if (lid.has_lid) { + int lid_open = getInt(LID_PATH); + if (lid_open!=lid.is_open) { + lid.is_open = lid_open; + if (state) *state = lid_open; + return 1; + } + } + return 0; +} + +/////////////////////////////// + +static SDL_Joystick **joysticks = NULL; +static int num_joysticks = 0; +void PLAT_initInput(void) { + if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) + LOG_error("Failed initializing joysticks: %s\n", SDL_GetError()); + num_joysticks = SDL_NumJoysticks(); + if (num_joysticks > 0) { + joysticks = (SDL_Joystick **)malloc(sizeof(SDL_Joystick *) * num_joysticks); + for (int i = 0; i < num_joysticks; i++) { + joysticks[i] = SDL_JoystickOpen(i); + LOG_info("Opening joystick %d: %s\n", i, SDL_JoystickName(joysticks[i])); + } + } +} + +void PLAT_quitInput(void) { + if (joysticks) { + for (int i = 0; i < num_joysticks; i++) { + if (SDL_JoystickGetAttached(joysticks[i])) { + LOG_info("Closing joystick %d: %s\n", i, SDL_JoystickName(joysticks[i])); + SDL_JoystickClose(joysticks[i]); + } + } + free(joysticks); + joysticks = NULL; + num_joysticks = 0; + } + SDL_QuitSubSystem(SDL_INIT_JOYSTICK); +} + +void PLAT_updateInput(const SDL_Event *event) { + switch (event->type) { + case SDL_JOYDEVICEADDED: { + int device_index = event->jdevice.which; + SDL_Joystick *new_joy = SDL_JoystickOpen(device_index); + if (new_joy) { + joysticks = realloc(joysticks, sizeof(SDL_Joystick *) * (num_joysticks + 1)); + joysticks[num_joysticks++] = new_joy; + LOG_info("Joystick added at index %d: %s\n", device_index, SDL_JoystickName(new_joy)); + } else { + LOG_error("Failed to open added joystick at index %d: %s\n", device_index, SDL_GetError()); + } + break; + } + + case SDL_JOYDEVICEREMOVED: { + SDL_JoystickID removed_id = event->jdevice.which; + for (int i = 0; i < num_joysticks; ++i) { + if (SDL_JoystickInstanceID(joysticks[i]) == removed_id) { + LOG_info("Joystick removed: %s\n", SDL_JoystickName(joysticks[i])); + SDL_JoystickClose(joysticks[i]); + + // Shift down the remaining entries + for (int j = i; j < num_joysticks - 1; ++j) + joysticks[j] = joysticks[j + 1]; + num_joysticks--; + + if (num_joysticks == 0) { + free(joysticks); + joysticks = NULL; + } else { + joysticks = realloc(joysticks, sizeof(SDL_Joystick *) * num_joysticks); + } + break; + } + } + break; + } + + default: + break; + } +} + +void PLAT_getBatteryStatus(int* is_charging, int* charge) { + PLAT_getBatteryStatusFine(is_charging, charge); + + // worry less about battery and more about the game you're playing + if (*charge>80) *charge = 100; + else if (*charge>60) *charge = 80; + else if (*charge>40) *charge = 60; + else if (*charge>20) *charge = 40; + else if (*charge>10) *charge = 20; + else *charge = 10; +} + +void PLAT_getCPUTemp() { + perf.cpu_temp = getInt("/sys/devices/virtual/thermal/thermal_zone0/temp")/1000; +} + +void PLAT_getCPUSpeed() +{ + perf.cpu_speed = getInt("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq")/1000; +} + +void PLAT_getGPUTemp() { + perf.gpu_temp = getInt("/sys/devices/virtual/thermal/thermal_zone1/temp")/1000; +} + +void PLAT_getGPUSpeed() { + // TODO + perf.gpu_speed = 42; // MHz +} + +static struct WIFI_connection connection = { + .valid = false, + .freq = -1, + .link_speed = -1, + .noise = -1, + .rssi = -1, + .ip = {0}, + .ssid = {0}, +}; + +static inline void connection_reset(struct WIFI_connection *connection_info) +{ + connection_info->valid = false; + connection_info->freq = -1; + connection_info->link_speed = -1; + connection_info->noise = -1; + connection_info->rssi = -1; + *connection_info->ip = '\0'; + *connection_info->ssid = '\0'; +} + +static bool bluetoothConnected = false; + +void PLAT_getNetworkStatus(int* is_online) +{ + if(WIFI_enabled()) + WIFI_connectionInfo(&connection); + else + connection_reset(&connection); + + if(is_online) + *is_online = (connection.valid && connection.ssid[0] != '\0'); + + if(BT_enabled()) { + bluetoothConnected = PLAT_bluetoothConnected(); + } + else + bluetoothConnected = false; +} + +void PLAT_getBatteryStatusFine(int* is_charging, int* charge) +{ + if(is_charging) { + int time_to_full = getInt("/sys/class/power_supply/axp2202-battery/time_to_full_now"); + int charger_present = getInt("/sys/class/power_supply/ac/online"); + *is_charging = (charger_present == 1) && (time_to_full > 0); + } + if(charge) { + *charge = getInt("/sys/class/power_supply/battery/capacity"); + } +} + +#define BLANK_PATH "/sys/class/backlight/backlight/bl_power" +void PLAT_enableBacklight(int enable) { + if (enable) { + putInt(BLANK_PATH, FB_BLANK_UNBLANK); // wake + SetBrightness(GetBrightness()); + } + else { + putInt(BLANK_PATH, FB_BLANK_POWERDOWN); // sleep + SetRawBrightness(0); + } +} + +void PLAT_powerOff(int reboot) { + if (CFG_getHaptics()) { + VIB_singlePulse(VIB_bootStrength, VIB_bootDuration_ms); + } + system("rm -f /tmp/nextui_exec && sync"); + sleep(2); + + SetRawVolume(MUTE_VOLUME_RAW); + PLAT_enableBacklight(0); + SND_quit(); + VIB_quit(); + PWR_quit(); + GFX_quit(); + + system("cat /dev/zero > /dev/fb0 2>/dev/null"); + if(reboot > 0) + touch("/tmp/reboot"); + else + touch("/tmp/poweroff"); + sync(); + exit(0); +} + +int PLAT_supportsDeepSleep(void) { return 1; } + +/////////////////////////////// + + +double get_time_sec() { + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC_RAW, &ts); + return ts.tv_sec + ts.tv_nsec / 1e9; // Convert to seconds +} +double get_process_cpu_time_sec() { + // this gives cpu time in nanoseconds needed to accurately calculate cpu usage in very short time frames. + // unfortunately about 20ms between meassures seems the lowest i can go to get accurate results + // maybe in the future i will find and even more granual way to get cpu time, but might just be a limit of C or Linux alltogether + struct timespec ts; + clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts); + return ts.tv_sec + ts.tv_nsec / 1e9; // Convert to seconds +} + +static pthread_mutex_t currentcpuinfo; +// a roling average for the display values of about 2 frames, otherwise they are unreadable jumping too fast up and down and stuff to read +#define ROLLING_WINDOW 120 + +volatile int useAutoCpu = 1; +void *PLAT_cpu_monitor(void *arg) { + struct timespec start_time, curr_time; + clock_gettime(CLOCK_MONOTONIC_RAW, &start_time); + + long clock_ticks_per_sec = sysconf(_SC_CLK_TCK); + + double prev_real_time = get_time_sec(); + double prev_cpu_time = get_process_cpu_time_sec(); + + // 408000 600000 816000 1104000 1416000 1608000 1800000 1992000 + const int cpu_frequencies[] = {408,600,816,1104,1416,1608,1800,1992}; + const int num_freqs = sizeof(cpu_frequencies) / sizeof(cpu_frequencies[0]); + int current_index = 1; + + double cpu_usage_history[ROLLING_WINDOW] = {0}; + double cpu_speed_history[ROLLING_WINDOW] = {0}; + int history_index = 0; + int history_count = 0; + + while (true) { + + double curr_real_time = get_time_sec(); + double curr_cpu_time = get_process_cpu_time_sec(); + + double elapsed_real_time = curr_real_time - prev_real_time; + double elapsed_cpu_time = curr_cpu_time - prev_cpu_time; + + if (useAutoCpu) { + double cpu_usage = 0; + + if (elapsed_real_time > 0) { + cpu_usage = (elapsed_cpu_time / elapsed_real_time) * 100.0; + } + + pthread_mutex_lock(¤tcpuinfo); + + // the goal here is is to keep cpu usage between 75% and 85% at the lowest possible speed so device stays cool and battery usage is at a minimum + // if usage falls out of this range it will either scale a step down or up + // but if usage hits above 95% we need that max boost and we instant scale up to 2000mhz as long as needed + // all this happens very fast like 60 times per second, so i'm applying roling averages to display values, so debug screen is readable and gives a good estimate on whats happening cpu wise + // the roling averages are purely for displaying, the actual scaling is happening realtime each run. + if (cpu_usage > 95) { + current_index = num_freqs - 1; // Instant power needed, cpu is above 95% Jump directly to max boost 2000MHz + } + else if (cpu_usage > 85 && current_index < num_freqs - 1) { // otherwise try to keep between 75 and 85 at lowest clock speed + current_index++; + } + else if (cpu_usage < 75 && current_index > 0) { + current_index--; + } + + PLAT_setCustomCPUSpeed(cpu_frequencies[current_index] * 1000); + + cpu_usage_history[history_index] = cpu_usage; + cpu_speed_history[history_index] = cpu_frequencies[current_index]; + + history_index = (history_index + 1) % ROLLING_WINDOW; + if (history_count < ROLLING_WINDOW) { + history_count++; + } + + double sum_cpu_usage = 0, sum_cpu_speed = 0; + for (int i = 0; i < history_count; i++) { + sum_cpu_usage += cpu_usage_history[i]; + sum_cpu_speed += cpu_speed_history[i]; + } + + perf.cpu_usage = sum_cpu_usage / history_count; + //perf.cpu_speed = sum_cpu_speed / history_count; + + pthread_mutex_unlock(¤tcpuinfo); + + prev_real_time = curr_real_time; + prev_cpu_time = curr_cpu_time; + // 20ms really seems lowest i can go, anything lower it becomes innacurate, maybe one day I will find another even more granual way to calculate usage accurately and lower this shit to 1ms haha, altough anything lower than 10ms causes cpu usage in itself so yeah + // Anyways screw it 20ms is pretty much on a frame by frame basis anyways, so will anything lower really make a difference specially if that introduces cpu usage by itself? + // Who knows, maybe some CPU engineer will find my comment here one day and can explain, maybe this is looking for the limits of C and needs Assambler or whatever to call CPU instructions directly to go further, but all I know is PUSH and MOV, how did the orignal Roller Coaster Tycoon developer wrote a whole game like this anyways? Its insane.. + usleep(20000); + + } else { + // Just measure CPU usage without changing frequency + + if (elapsed_real_time > 0) { + double cpu_usage = (elapsed_cpu_time / elapsed_real_time) * 100.0; + + pthread_mutex_lock(¤tcpuinfo); + + cpu_usage_history[history_index] = cpu_usage; + + history_index = (history_index + 1) % ROLLING_WINDOW; + if (history_count < ROLLING_WINDOW) { + history_count++; + } + + double sum_cpu_usage = 0; + for (int i = 0; i < history_count; i++) { + sum_cpu_usage += cpu_usage_history[i]; + } + + perf.cpu_usage = sum_cpu_usage / history_count; + + pthread_mutex_unlock(¤tcpuinfo); + } + + prev_real_time = curr_real_time; + prev_cpu_time = curr_cpu_time; + usleep(100000); + } + } +} + + +#define GOVERNOR_PATH "/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed" +void PLAT_setCustomCPUSpeed(int speed) { + FILE *fp = fopen(GOVERNOR_PATH, "w"); + if (fp == NULL) { + perror("Failed to open scaling_setspeed"); + return; + } + + fprintf(fp, "%d\n", speed); + fclose(fp); +} +void PLAT_setCPUSpeed(int speed) { + int freq = 0; + switch (speed) { + case CPU_SPEED_MENU: freq = 600000; perf.cpu_speed = 600; break; + case CPU_SPEED_POWERSAVE: freq = 1200000; perf.cpu_speed = 1200; break; + case CPU_SPEED_NORMAL: freq = 1608000; perf.cpu_speed = 1600; break; + case CPU_SPEED_PERFORMANCE: freq = 2000000; perf.cpu_speed = 2000; break; + } + putInt(GOVERNOR_PATH, freq); +} + + +#define RUMBLE_PATH "/sys/class/gpio/gpio20/value" +void PLAT_setRumble(int strength) { + if (GetHDMI()) return; // assume we're using a controller? + putInt(RUMBLE_PATH, strength?1:0); +} + +int PLAT_pickSampleRate(int requested, int max) { + // bluetooth: allow limiting the maximum to improve compatibility + if(PLAT_bluetoothConnected()) + return MIN(requested, CFG_getBluetoothSamplingrateLimit()); + + return MIN(requested, max); +} + +char* PLAT_getModel(void) { + return "Miyoo Flip"; +} + +void PLAT_getOsVersionInfo(char* output_str, size_t max_len) +{ + // TODO + return; +} + +bool PLAT_btIsConnected(void) +{ + return bluetoothConnected; +} + +ConnectionStrength PLAT_connectionStrength(void) { + if(!WIFI_enabled() || !connection.valid || connection.rssi == -1) + return SIGNAL_STRENGTH_OFF; + else if (connection.rssi == 0) + return SIGNAL_STRENGTH_DISCONNECTED; + else if (connection.rssi >= -60) + return SIGNAL_STRENGTH_HIGH; + else if (connection.rssi >= -70) + return SIGNAL_STRENGTH_MED; + else + return SIGNAL_STRENGTH_LOW; +} + +void PLAT_initDefaultLeds() { + +} +void PLAT_initLeds(LightSettings *lights) { + +} + +#define LED_PATH1 "/sys/class/led_anim/max_scale" +#define LED_PATH2 "/sys/class/led_anim/max_scale_lr" +#define LED_PATH3 "/sys/class/led_anim/max_scale_f1f2" + +void PLAT_setLedInbrightness(LightSettings *led) +{ + +} +void PLAT_setLedBrightness(LightSettings *led) +{ + +} +void PLAT_setLedEffect(LightSettings *led) +{ + +} +void PLAT_setLedEffectCycles(LightSettings *led) +{ + + +} +void PLAT_setLedEffectSpeed(LightSettings *led) +{ + +} +void PLAT_setLedColor(LightSettings *led) +{ + +} + +////////////////////////////////////////////// + +int PLAT_setDateTime(int y, int m, int d, int h, int i, int s) { + char cmd[512]; + sprintf(cmd, "date -s '%d-%d-%d %d:%d:%d'; hwclock -u -w", y,m,d,h,i,s); + system(cmd); + return 0; // why does this return an int? +} + +#define MAX_LINE_LENGTH 200 +#define ZONE_PATH "/usr/share/zoneinfo" +#define ZONE_TAB_PATH ZONE_PATH "/zone.tab" + +static char cached_timezones[MAX_TIMEZONES][MAX_TZ_LENGTH]; +static int cached_tz_count = -1; + +int compare_timezones(const void *a, const void *b) { + return strcmp((const char *)a, (const char *)b); +} + +void PLAT_initTimezones() { + if (cached_tz_count != -1) { // Already initialized + return; + } + + FILE *file = fopen(ZONE_TAB_PATH, "r"); + if (!file) { + LOG_info("Error opening file %s\n", ZONE_TAB_PATH); + return; + } + + char line[MAX_LINE_LENGTH]; + cached_tz_count = 0; + + while (fgets(line, sizeof(line), file)) { + // Skip comment lines + if (line[0] == '#' || strlen(line) < 3) { + continue; + } + + char *token = strtok(line, "\t"); // Skip country code + if (!token) continue; + + token = strtok(NULL, "\t"); // Skip latitude/longitude + if (!token) continue; + + token = strtok(NULL, "\t\n"); // Extract timezone + if (!token) continue; + + // Check for duplicates before adding + int duplicate = 0; + for (int i = 0; i < cached_tz_count; i++) { + if (strcmp(cached_timezones[i], token) == 0) { + duplicate = 1; + break; + } + } + + if (!duplicate && cached_tz_count < MAX_TIMEZONES) { + strncpy(cached_timezones[cached_tz_count], token, MAX_TZ_LENGTH - 1); + cached_timezones[cached_tz_count][MAX_TZ_LENGTH - 1] = '\0'; // Ensure null-termination + cached_tz_count++; + } + } + + fclose(file); + + // Sort the list alphabetically + qsort(cached_timezones, cached_tz_count, MAX_TZ_LENGTH, compare_timezones); +} + +void PLAT_getTimezones(char timezones[MAX_TIMEZONES][MAX_TZ_LENGTH], int *tz_count) { + if (cached_tz_count == -1) { + LOG_warn("Error: Timezones not initialized. Call PLAT_initTimezones first.\n"); + *tz_count = 0; + return; + } + + memcpy(timezones, cached_timezones, sizeof(cached_timezones)); + *tz_count = cached_tz_count; +} + +char *PLAT_getCurrentTimezone() { + // easy enough, get current index from config and return the string + int tz_index = CFG_getCurrentTimezone(); + if (tz_index < 0 || tz_index >= cached_tz_count) { + LOG_warn("Error: Current timezone index %d out of bounds.\n", tz_index); + return NULL; + } + + char *output = (char *)malloc(256); + if (!output) + return NULL; + + strncpy(output, cached_timezones[tz_index], 256 - 1); + output[256 - 1] = '\0'; // Ensure null-termination + + return output; +} + +void PLAT_setCurrentTimezone(const char* tz) { + if (cached_tz_count == -1) { + LOG_warn("Error: Timezones not initialized. Call PLAT_initTimezones first.\n"); + return; + } + + if(!tz || strlen(tz) == 0) { + LOG_warn("Error: Invalid timezone string.\n"); + return; + } + + // get index of timezone + int tz_index = -1; + for (int i = 0; i < cached_tz_count; i++) { + if (strcmp(cached_timezones[i], tz) == 0) { + tz_index = i; + break; + } + } + + if (tz_index == -1) { + LOG_warn("Error: Timezone %s not found in cached list.\n", tz); + return; + } + + // set in config + CFG_setCurrentTimezone(tz_index); + + // This fixes the timezone until the next reboot + char *tz_path = (char *)malloc(256); + if (!tz_path) { + return; + } + snprintf(tz_path, 256, ZONE_PATH "/%s", tz); + // replace existing symlink + if (unlink("/tmp/localtime") == -1) { + LOG_debug("Failed to remove existing symlink: %s\n", strerror(errno)); + } + if (symlink(tz_path, "/tmp/localtime") == -1) { + LOG_error("Failed to set timezone: %s\n", strerror(errno)); + } + free(tz_path); + + // apply timezone to RTC and kernel + system("hwclock -u -w && hwclock --systz -u"); +} + +bool PLAT_getNetworkTimeSync(void) { + return CFG_getNTP(); +} + +void PLAT_setNetworkTimeSync(bool on) { + CFG_setNTP(on); + if (on) { + system("/etc/init.d/S49ntp restart &"); + } else { + system("/etc/init.d/S49ntp stop &"); + } +} + +///////////////////////// + +// We use the generic video implementation here +#include "generic_video.c" + +///////////////////////// + +// We use the generic wifi implementation here +#include "generic_wifi.c" + +///////////////////////// + +// We use the generic bluetooth implementation here +#include "generic_bt.c" diff --git a/workspace/my355/platform/platform.h b/workspace/my355/platform/platform.h new file mode 100755 index 000000000..06067133d --- /dev/null +++ b/workspace/my355/platform/platform.h @@ -0,0 +1,146 @@ +// my355/platform/platform.h + +#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_POWER BUTTON_NA +#define BUTTON_PLUS BUTTON_NA +#define BUTTON_MINUS BUTTON_NA + +/////////////////////////////// + +#define CODE_UP 82 +#define CODE_DOWN 81 +#define CODE_LEFT 80 +#define CODE_RIGHT 79 + +#define CODE_SELECT 228 +#define CODE_START 40 + +#define CODE_A 44 +#define CODE_B 224 +#define CODE_X 225 +#define CODE_Y 226 + +#define CODE_L1 43 +#define CODE_R1 42 +#define CODE_L2 75 +#define CODE_R2 78 +#define CODE_L3 230 +#define CODE_R3 229 + +#define CODE_MENU 41 +#define CODE_POWER 102 + +#define CODE_PLUS 128 +#define CODE_MINUS 129 + +/////////////////////////////// + +#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 + +#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 AXIS_LX 0 +#define AXIS_LY 1 +#define AXIS_RX 3 +#define AXIS_RY 4 + +/////////////////////////////// + +#define BTN_RESUME BTN_X +#define BTN_SLEEP BTN_POWER +#define BTN_WAKE BTN_POWER +#define BTN_MOD_VOLUME BTN_NONE +#define BTN_MOD_BRIGHTNESS BTN_MENU +#define BTN_MOD_PLUS BTN_PLUS +#define BTN_MOD_MINUS BTN_MINUS +#define BTN_MOD_COLORTEMP BTN_NONE + +/////////////////////////////// + +extern int on_hdmi; + +#define FIXED_SCALE 2 +#define FIXED_WIDTH 640 +#define FIXED_HEIGHT 480 +#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) + +// TODO: if HDMI_HEIGHT > FIXED_HEIGHT then MAIN_ROW_COUNT will be insufficient + +/////////////////////////////// + +#define MAIN_ROW_COUNT (on_hdmi?8:6) +#define PADDING (on_hdmi?40:10) + +/////////////////////////////// + +#define SDCARD_PATH "/mnt/SDCARD" +#define MUTE_VOLUME_RAW 0 +// #define HAS_NEON + +// this should be set to the devices native screen refresh rate +#define SCREEN_FPS 60.0 +/////////////////////////////// + +#endif