Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/hakchi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormadmonkey <madfkingmonkey@gmail.com>2017-12-19 01:59:51 +0300
committermadmonkey <madfkingmonkey@gmail.com>2017-12-19 01:59:51 +0300
commita76933c3275f0928604f0f17f727a836cdc6dddf (patch)
treeb41659e1e6250f692253cf3211c50a508f279ca1
parent395539c0c65942b732a7f11b3a647ca390110269 (diff)
fixes
-rw-r--r--README.md3
-rw-r--r--mod/hakchi/config9
-rw-r--r--mod/hakchi/init5
-rwxr-xr-xmod/hakchi/rootfs/bin/chmenu24
-rwxr-xr-xmod/hakchi/rootfs/bin/hsqs3
-rw-r--r--mod/hakchi/rootfs/etc/preinit.d/b0010_functions91
-rw-r--r--mod/hakchi/rootfs/etc/preinit.d/b0040_usb31
-rw-r--r--mod/hakchi/rootfs/etc/preinit.d/p0000_config2
-rw-r--r--mod/hakchi/rootfs/etc/preinit.d/p7010_bootlogo1
-rw-r--r--mod/hakchi/rootfs/etc/preinit.d/p7020_usb3
-rw-r--r--mod/hakchi/rootfs/etc/preinit.d/p7070_firmware3
11 files changed, 106 insertions, 69 deletions
diff --git a/README.md b/README.md
index bf0f510..8bfb376 100644
--- a/README.md
+++ b/README.md
@@ -5,8 +5,7 @@ Clone the repo:
```
git clone git@github.com:madmonkey1907/hakchi.git
cd hakchi
-git submodule init
-git submodule update
+git submodule update --init --recursive
```
## Install the build dependencies
diff --git a/mod/hakchi/config b/mod/hakchi/config
index 6e90132..25b5876 100644
--- a/mod/hakchi/config
+++ b/mod/hakchi/config
@@ -1,5 +1,4 @@
-local cf_backup_dummy='n'
-local cf_backup='n'
-local cf_backup_nandc='n'
-local cf_shutdown='n'
-local cf_usb='y'
+export cf_backup_dummy='n'
+export cf_backup='n'
+export cf_backup_nandc='n'
+export cf_shutdown='n'
diff --git a/mod/hakchi/init b/mod/hakchi/init
index 50fc66a..023db13 100644
--- a/mod/hakchi/init
+++ b/mod/hakchi/init
@@ -6,6 +6,7 @@ init(){
export modpath="/$modname"
export mountpoint="/newroot"
export temppath="/tmp"
+ echo "$modname init script version: 1.0"
/bin/busybox --install -s /bin/
mkdir -p "$temppath"
@@ -18,15 +19,15 @@ init(){
source "$modpath/script/base"
if [ -d "$modpath/transfer" ]; then
- export cf_usb='n'
source "$modpath/script/transfer"
else
mount_base
fi
if [ -f "$preinit" ]; then
+ export preinit
PATH="$rootfs/sbin:$rootfs/usr/sbin:$rootfs/bin:$rootfs/usr/bin:$PATH"
- "$rootfs/bin/busybox" sh -c "source "$preinit.d/b0000_defines" && source "$preinit" && preinit"
+ "$rootfs/bin/busybox" sh -c "source "$preinit" && preinit"
else
umount_base
fi
diff --git a/mod/hakchi/rootfs/bin/chmenu b/mod/hakchi/rootfs/bin/chmenu
index 3ad32b8..bf4ebde 100755
--- a/mod/hakchi/rootfs/bin/chmenu
+++ b/mod/hakchi/rootfs/bin/chmenu
@@ -2,34 +2,20 @@
source /etc/preinit
script_init
-state_file="$installpath/menu"
+gameStorage="$installpath/games"
+state_file="$gameStorage/menu.txt"
[ -z "$1" ] && exit 1
[ -f "$state_file" ] && prev_code="$(cat "$state_file")" || prev_code="000"
[ "$1" == "$prev_code" ] && exit 1
echo "Switching to menu $1"
-if [ "$1" == "000" ]; then
- targetpath="$rootfs$gamepath"
-else
- targetpath="$rootfs$gamepath/$1"
-fi
-
-[ -d "$targetpath" ] || exit 1
+targetpath="$gameStorage/$1"
+containsGames "$targetpath" || exit 1
echo "$1" > "$state_file"
echo "New directory: $targetpath"
-
-if [ "$1" != "000" ]; then
- if [ -f "$rootfs$gamepath/title.fnt" ] && [ ! -f "$targetpath/title.fnt" ]; then
- ln -s "$rootfs$gamepath/title.fnt" "$targetpath/title.fnt"
- fi
- if [ -f "$rootfs$gamepath/copyright.fnt" ] && [ ! -f "$targetpath/copyright.fnt" ]; then
- ln -s "$rootfs$gamepath/copyright.fnt" "$targetpath/copyright.fnt"
- fi
-fi
-
uistop
-overmount_games
+overmount_games "$1"
sleep 1
touch "/var/startmcp.flag"
diff --git a/mod/hakchi/rootfs/bin/hsqs b/mod/hakchi/rootfs/bin/hsqs
index 800c456..041654f 100755
--- a/mod/hakchi/rootfs/bin/hsqs
+++ b/mod/hakchi/rootfs/bin/hsqs
@@ -6,7 +6,7 @@ echo "current firmware: $(currentFirmware)"
printSoftwareInfo
firmware="$1"
-if [ "$firmware" != "_nand_" ]; then
+if [ "$firmware" != "auto" ] && [ "$firmware" != "_nand_" ]; then
firmware="$(echo "$firmware" | sed -re 's/^\/usr\/share\/games\/(nes\/kachikachi\/)?/\/var\/games\//')"
firmware="$(readlink -f "$firmware")"
checkFirmware "$firmware" || exit 1
@@ -17,6 +17,7 @@ cfg_firmware="$firmware"
save_config
[ "$(currentFirmware)" == "$firmware" ] && exit 0
+[ "$(currentFirmware)" == "auto" ] && exit 0 #?
echo "changing firmware to: $firmware"
reboot
diff --git a/mod/hakchi/rootfs/etc/preinit.d/b0010_functions b/mod/hakchi/rootfs/etc/preinit.d/b0010_functions
index 7ec9965..b1b5a23 100644
--- a/mod/hakchi/rootfs/etc/preinit.d/b0010_functions
+++ b/mod/hakchi/rootfs/etc/preinit.d/b0010_functions
@@ -75,7 +75,10 @@ remount_root(){
mount_move l media
mount_move l var
+ stopTask decodepng
+ stopTask aplay
umount "$mountpoint"
+
local loopfile="/var${1##$mountpoint/var}"
[ -f "$loopfile" ] || loopfile="/media${1##$mountpoint/media}"
if ! mount -o loop,ro,noatime "$loopfile" "$mountpoint"; then
@@ -109,6 +112,16 @@ currentFirmware(){
return 1
}
+overmountModules(){
+ if [ ! -d "$mountpoint/lib/modules/$(uname -r)" ]; then
+ if [ -d "$rootfs/lib/modules/$(uname -r)" ]; then
+ overmount "/lib/modules"
+ else
+ echo "no modules for loaded kernel $(uname -r)"
+ fi
+ fi
+}
+
loadFirmware(){
[ -z "$(mount | grep -F loop0)" ] || return 1
@@ -125,13 +138,7 @@ loadFirmware(){
remount_root "$firmware"
cryptsetup close root-crypt
mountSquash
- if [ ! -d "$mountpoint/lib/modules/$(uname -r)" ]; then
- if [ -d "$rootfs/lib/modules/$(uname -r)" ]; then
- overmount "/lib/modules"
- else
- echo "no modules for loaded kernel $(uname -r)"
- fi
- fi
+ overmountModules
}
shutdown(){
@@ -205,7 +212,7 @@ containsGames(){
}
linkGames(){
- local games="$mountpoint/media/$modname/games${1##$rootfs$gamepath}"
+ local games="$mountpoint/media/$modname/games${1##$installpath/games}"
[ -d "$games" ] || games="$installpath/games${1##$rootfs$gamepath}"
[ -d "$games" ] || games="$1"
games="${games##$mountpoint}"
@@ -231,7 +238,7 @@ softwareCheck(){
[ -d "$feck" ] && rm -rf "$feck.snes" && mv "$feck" "$feck.snes"
[ -f "$feck.nes" ] && mv -f "$feck.nes" "$feck"
fi
-
+
rm -f "$mountpoint/var/saves"
ln -s "/var/lib/clover/profiles/0" "$mountpoint/var/saves"
}
@@ -239,23 +246,23 @@ softwareCheck(){
repair_fonts(){
if [ "$sftype" == "nes" ]; then
mkdir -p "$1" || return 1
- [ ! -f "$1/title.fnt" ] && (cp $rootfs$gamepath/title.fnt "$1" || cp $squashfs$gamepath/title.fnt "$1")
- [ ! -f "$1/copyright.fnt" ] && (cp $rootfs$gamepath/copyright.fnt "$1" || cp $squashfs$gamepath/copyright.fnt "$1")
+ [ ! -f "$1/title.fnt" ] && (copy "$rootfs$gamepath/title.fnt" "$1" || copy "$squashfs$gamepath/title.fnt" "$1")
+ [ ! -f "$1/copyright.fnt" ] && (copy "$rootfs$gamepath/copyright.fnt" "$1" || copy "$squashfs$gamepath/copyright.fnt" "$1")
fi
}
repair_games(){
[ -w "$1" ] || return 0
local usesymlink=''
- ln -s / "$1/symlinktest" && rm "$1/symlinktest" && usesymlink='y'
-
+ ln -s / "$1/symlinktest" 2>/dev/null && rm -f "$1/symlinktest" && usesymlink='y'
+
ls -1 "$squashfs$gamepath" | grep CLV- | while read code
do
local gamedir="$1/$code"
local squashgamedir="$squashfs$gamepath/$code"
-
+
[ -d "$gamedir" ] || continue
-
+
if [ ! -f "$gamedir/$code.desktop" ]; then
cp "$squashgamedir/$code.desktop" "$gamedir/"
[ "$sftype" == "nes" ] && \
@@ -263,10 +270,10 @@ repair_games(){
[ "$sftype" == "snes" ] && \
sed -i -e 's#/usr/bin/clover-canoe-shvc#/bin/clover-canoe-shvc-wr#g' "$gamedir/$code.desktop"
fi
-
- [ -d "$gamedir/autoplay/" ] && ([ "$(ls -A "$gamedir/autoplay/")" ] || rm -r "$gamedir/autoplay/")
- [ -d "$gamedir/pixelart/" ] && ([ "$(ls -A "$gamedir/pixelart/")" ] || rm -r "$gamedir/pixelart/")
-
+
+ [ -d "$gamedir/autoplay/" ] && ([ "$(ls -A "$gamedir/autoplay/")" ] || rm -rf "$gamedir/autoplay/")
+ [ -d "$gamedir/pixelart/" ] && ([ "$(ls -A "$gamedir/pixelart/")" ] || rm -rf "$gamedir/pixelart/")
+
find "$squashgamedir" -maxdepth 1 | sed -n '1!p' | while read squashfile
do
if [ "$usesymlink" == "y" ]; then
@@ -281,12 +288,17 @@ repair_games(){
}
overmount_games(){
- local menu_code="000"
- [ -f "$installpath/menu" ] && menu_code="$(cat "$installpath/menu")"
- containsGames "$rootfs$gamepath/$menu_code" || menu_code=""
+ local gameStorage="$installpath/games"
+ local menu_code="$1"
+ [ -z "$1" ] && menucode="000"
+ [ -z "$1" ] && [ -f "$gameStorage/menu.txt" ] && menu_code="$(cat "$gameStorage/menu.txt")"
+ containsGames "$gameStorage/$menu_code" || menu_code=""
echo "menu code: $menu_code"
- if containsGames "$rootfs$gamepath/$menu_code"; then
- overmount "$gamepath/$menu_code" "$gamepath" && repair_games "$rootfs$gamepath/$menu_code" && linkGames "$rootfs$gamepath/$menu_code" && return 0
+ if containsGames "$gameStorage/$menu_code"; then
+ overmount "/../games/$menu_code" "$gamepath" && \
+ repair_games "$gameStorage/$menu_code" && \
+ linkGames "$gameStorage/$menu_code" && \
+ return 0
else
echo "no romz found at: $rootfs$gamepath/$menu_code"
fi
@@ -330,12 +342,41 @@ printSoftwareInfo(){
echo "region=$sfregion"
}
+stopTask(){
+ local tokill="false"
+ if [ "$1" = "-f" ]; then
+ tokill="true"
+ shift
+ fi
+ local pid="$(pidof "$1")"
+ [ -z "$pid" ] && return 0
+ "$tokill" && kill "$pid"
+ wait "$pid"
+}
+
+waitTask(){
+ local A="stopTask ${1+"$@"}"
+ trap "$A" EXIT
+}
+
showImage(){
- image="$(eval echo "$1")"
+ local image="$(eval echo "$1")"
[ -f "$image" ] || image="$rootfs$1"
[ -f "$image" ] || image="$squashfs$1"
[ -f "$image" ] || return 1
decodepng "$image" > "/dev/fb0" &
+ waitTask decodepng
+ return 0
+}
+
+
+playSound(){
+ local wavfile="$(eval echo "$1")"
+ [ -f "$wavfile" ] || wavfile="$rootfs$1"
+ [ -f "$wavfile" ] || wavfile="$squashfs$1"
+ [ -f "$wavfile" ] || return 1
+ aplay -q "$wavfile" &
+ waitTask aplay
return 0
}
diff --git a/mod/hakchi/rootfs/etc/preinit.d/b0040_usb b/mod/hakchi/rootfs/etc/preinit.d/b0040_usb
index f6facc8..e2554fb 100644
--- a/mod/hakchi/rootfs/etc/preinit.d/b0040_usb
+++ b/mod/hakchi/rootfs/etc/preinit.d/b0040_usb
@@ -1,24 +1,24 @@
disableUsbDevice(){
#disable usb
+ [ -f "/sys/devices/sunxi_usb/usb_role" ] || return 1
echo 0 > "/sys/devices/sunxi_usb/usb_role"
}
switchToUsbDevice(){
+ [ -f "/sys/devices/sunxi_usb/usb_role" ] || return 1
disableUsbDevice
-
# enable device mode
echo 2 > "/sys/devices/sunxi_usb/usb_role"
-
# make sure the usb gadgets are disabled
echo 0 > "/sys/devices/virtual/android_usb/android0/enable"
}
switchToUsbHost(){
+ [ -f "/sys/devices/sunxi_usb/usb_role" ] || return 1
# make sure the usb gadgets are disabled
+ [ -f "/sys/devices/virtual/android_usb/android0/enable" ] && \
echo 0 > "/sys/devices/virtual/android_usb/android0/enable"
-
disableUsbDevice
-
# enable host mode
echo 1 > "/sys/devices/sunxi_usb/usb_role"
}
@@ -63,9 +63,19 @@ checkUsbStorage(){
showImage "$bootlogo2"
cfg_boot_logo=''
else
- [ -f "$bootlogo2" ] && rm "$bootlogo2" && source "$preinit.d/p7010_bootlogo"
+ [ -f "$bootlogo2" ] && rm -f "$bootlogo2" && source "$preinit.d/p7010_bootlogo"
fi
-
+
+ local bootsound0="boot.wav"
+ local bootsound1="$mountpoint/media/$modname/$bootsound0"
+ local bootsound2="$rootfs/etc/$bootsound0"
+ if [ -f "$bootsound1" ]; then
+ [ -f "$bootsound2" ] || playSound "$bootsound1"
+ rsync -ac "$bootsound1" "$bootsound2"
+ else
+ rm -f "$bootsound2"
+ fi
+
return 0
}
@@ -74,12 +84,13 @@ checkUsbGamepath(){
[ -b "$disk" ] || return 1
local games="$modname/games"
+ local gameStorage="$installpath/games"
if containsGames "$mountpoint/media/$games"; then
- if ! mkdir -p "$rootfs$gamepath"; then
- rm -rf "$rootfs$gamepath"
- mkdir -p "$rootfs$gamepath" || return 1
+ if ! mkdir -p "$gameStorage"; then
+ rm -rf "$gameStorage"
+ mkdir -p "$gameStorage" || return 1
fi
- mount_bind "$mountpoint/media/$games" "$rootfs$gamepath"
+ mount_bind "$mountpoint/media/$games" "$gameStorage"
return 0
else
echo "no romz found at: $disk:/$games"
diff --git a/mod/hakchi/rootfs/etc/preinit.d/p0000_config b/mod/hakchi/rootfs/etc/preinit.d/p0000_config
index c1d33a3..f1a2b8c 100644
--- a/mod/hakchi/rootfs/etc/preinit.d/p0000_config
+++ b/mod/hakchi/rootfs/etc/preinit.d/p0000_config
@@ -1,5 +1,5 @@
cfg_boot_stock='n'
cfg_disable_armet='y'
cfg_firmware='auto'
-cfg_nes_extra_args='--ppu-palette 2'
+cfg_nes_extra_args=''
cfg_usb_host='y'
diff --git a/mod/hakchi/rootfs/etc/preinit.d/p7010_bootlogo b/mod/hakchi/rootfs/etc/preinit.d/p7010_bootlogo
index 9675ad2..4a5e3f1 100644
--- a/mod/hakchi/rootfs/etc/preinit.d/p7010_bootlogo
+++ b/mod/hakchi/rootfs/etc/preinit.d/p7010_bootlogo
@@ -1 +1,2 @@
showImage "$cfg_boot_logo" || showImage "$rootfs/etc/boot.png" || showImage "$rootfs/etc/$modname.png"
+playSound "$rootfs/etc/boot.wav"
diff --git a/mod/hakchi/rootfs/etc/preinit.d/p7020_usb b/mod/hakchi/rootfs/etc/preinit.d/p7020_usb
index 1ee0c31..0847136 100644
--- a/mod/hakchi/rootfs/etc/preinit.d/p7020_usb
+++ b/mod/hakchi/rootfs/etc/preinit.d/p7020_usb
@@ -1,13 +1,12 @@
if [ "$cfg_usb_host" != "y" ]; then
switchToUsbDevice
else
+ switchToUsbHost
# the usb driver needs some time to initialize
sleep 1
-
if [ -z "$(lsusb | grep -v "1d6b:0001")" ]; then
switchToUsbDevice
else
checkUsbStorage
fi
-
fi
diff --git a/mod/hakchi/rootfs/etc/preinit.d/p7070_firmware b/mod/hakchi/rootfs/etc/preinit.d/p7070_firmware
index fbe018a..b351b0e 100644
--- a/mod/hakchi/rootfs/etc/preinit.d/p7070_firmware
+++ b/mod/hakchi/rootfs/etc/preinit.d/p7070_firmware
@@ -4,5 +4,4 @@ mod_repair_etc
softwareCheck
checkUsbGamepath
-# temporary
-[ "$(uname -n)" == "madmonkey" ] && overmount "/lib/modules"
+overmountModules