Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PICO-8/Splore to Expert #1331

Merged
merged 20 commits into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 82 additions & 11 deletions static/build/.tmp_update/script/stop_audioserver.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,92 @@
#!/bin/sh

curvol=$(cat /proc/mi_modules/mi_ao/mi_ao0 | awk '/LineOut/ {if (!printed) {print $8; printed=1}}' | sed 's/,//')
get_curvol() {
awk '/LineOut/ {if (!printed) {gsub(",", "", $8); print $8; printed=1}}' /proc/mi_modules/mi_ao/mi_ao0
}

get_curmute() {
awk '/LineOut/ {if (!printed) {gsub(",", "", $8); print $6; printed=1}}' /proc/mi_modules/mi_ao/mi_ao0
}

is_process_running() {
process_name="$1"
if [ -z "$(pgrep -f "$process_name")" ]; then
return 1
else
return 0
fi
}

pkill -9 -f audioserver
killall audioserver.mod 2> /dev/null
# when wifi is restarted, udhcpc and wpa_supplicant may be started with libpadsp.so preloaded, this is bad as they can hold mi_ao open even after audioserver has been killed.
libpadspblocker() {
wpa_pid=$(ps -e | grep "[w]pa_supplicant" | awk 'NR==1{print $1}')
udhcpc_pid=$(ps -e | grep "[u]dhcpc" | awk 'NR==1{print $1}')
if [ -n "$wpa_pid" ] && [ -n "$udhcpc_pid" ]; then
if grep -q "libpadsp.so" /proc/$wpa_pid/maps || grep -q "libpadsp.so" /proc/$udhcpc_pid/maps; then
echo "Network Checker: $wpa_pid(WPA) and $udhcpc_pid(UDHCPC) found preloaded with libpadsp.so"
unset LD_PRELOAD
killall -9 wpa_supplicant
killall -9 udhcpc
$miyoodir/app/wpa_supplicant -B -D nl80211 -iwlan0 -c /appconfigs/wpa_supplicant.conf &
udhcpc -i wlan0 -s /etc/init.d/udhcpc.script &
echo "Network Checker: Removing libpadsp.so preload on wpa_supp/udhcpc"
fi
fi
}

kill_audio_servers() {
is_process_running "audioserver" && pkill -9 -f "audioserver"
is_process_running "audioserver.mod" && killall -q "audioserver.mod"
}

set_snd_level() {
for i in $(seq 1 300); do
if [ -e /proc/mi_modules/mi_ao/mi_ao0 ]; then
echo "set_ao_volume 0 ${curvol}dB" > /proc/mi_modules/mi_ao/mi_ao0
echo "set_ao_volume 1 ${curvol}dB" > /proc/mi_modules/mi_ao/mi_ao0
echo "Volume set to ${curvol}dB"
break
local target_vol="$1"
local target_mute="$2"
local current_vol
local current_mute
local start_time
local elapsed_time

start_time=$(date +%s)
while [ ! -e /proc/mi_modules/mi_ao/mi_ao0 ]; do
sleep 0.2
elapsed_time=$(($(date +%s) - start_time))
if [ "$elapsed_time" -ge 30 ]; then
echo "Timed out waiting for /proc/mi_modules/mi_ao/mi_ao0"
return 1
fi
sleep 0.1
done

start_time=$(date +%s)
while true; do
echo "set_ao_volume 0 ${target_vol}dB" >/proc/mi_modules/mi_ao/mi_ao0
echo "set_ao_volume 1 ${target_vol}dB" >/proc/mi_modules/mi_ao/mi_ao0
echo "set_ao_mute ${target_mute}" >/proc/mi_modules/mi_ao/mi_ao0

current_vol=$(get_curvol)
current_mute=$(get_curmute)

if [ "$current_vol" = "$target_vol" ] && [ "$current_mute" = "$target_mute" ]; then
echo "Volume set to ${current_vol}dB, Mute status: ${current_mute}"
return 0
fi

elapsed_time=$(($(date +%s) - start_time))
if [ "$elapsed_time" -ge 360 ]; then
echo "Timed out trying to set volume and mute status"
return 1
fi

sleep 0.2
done
}

main() {
curvol=$(get_curvol)
curmute=$(get_curmute)
kill_audio_servers
libpadspblocker
set_snd_level "${curvol}" "${curmute}" &
}

set_snd_level &
main
Binary file added static/build/Icons/Default/rapp/pico-8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Configuration for pico-8
//
// config.txt is read on startup and saved on exit.
// To generate the default config.txt, delete this file.
//
// - - - - - - - - - - - - - - - - - - - - - - - - - - - -


// :: Video Settings

window_size 640 480 // window width, height
screen_size 640 480 // screen width, height (stretched to window)
show_fps 0 // Draw frames per second in the corner


// :: Window Settings

windowed 0 // 1 to start up in windowed mode
window_position -1 -1 // x and y position of window (-1, -1 to let the window manager decide)
frameless 1 // 1 to use a window with no frame
fullscreen_method 0 // 0 maximized window (linux) 1 borderless desktop-sized window 2 hardware fullscreen (warning: erratic behaviour under some drivers)
blit_method 2 // 0 auto 1 software (slower but sometimes more reliable) 2 hardware (can do filtered scaling)



// :: System Settings

foreground_sleep_ms 5 // number of milliseconds to sleep each frame. Try 10 to conserve battery power

background_sleep_ms 10 // number of milliseconds to sleep each frame when running in the background

sessions 0 // number of times program has been run

// (scancode) hold this key down and left-click to simulate right-click
rmb_key 0 // 0 for none 226 for LALT

// Desktop for saving screenshots etc. Defaults to $HOME/Desktop
desktop_path

// 1 to allow controller input even when application is in background
read_controllers_in_background 0



// :: Audio Settings (use "volume" for PICO-8)

sound_volume 256 // 0..256
music_volume 256 // 0..256


// :: usually 1024. Try 2048 if you get choppy sound

mix_buffer_size 1024


// :: map scancodes. Format: 44=47,80=89,.. (scancode a, scancode b -- when press a, generates b)
// run the program with -scancodes to determine which scancodes to use
map_scancodes


// :: pico-8

version 0.2.5g

// audio volume: 0..256
volume 256


// Location of pico-8's root folder
root_path /mnt/SDCARD/Roms/PICO/


// Location of cartridge save data
cdata_path /mnt/SDCARD/Saves/CurrentProfile/saves/PICO-8/.lexaloffle/pico-8/cdata/


// Specify which player index joystick control begins at (0..7)
joystick_index 0


// Custom keyboard scancodes for buttons. player0 0..6, player1 0..5
button_keys 0 0 0 0 0 0 0 0 0 0 0 0 0

// Play notes as they are plotted in frequency mode
live_notes 0

// iff 1: when using keyboard cursor, snap to closest pixel / map cel
cursor_snap 0

// 0 default 1 dark blue background in code editor 2 black background in code editor 3 gray background in code editor
gui_theme 0

// scale of screenshots and gifs // 2 means 256x256
screenshot_scale 3
gif_scale 2

// maximum gif length in seconds (0..120; 0 means no gif recording)
gif_len 8

// when 1, reset the recording when pressing ctrl-9 (useful for creating a non-overlapping sequence)
gif_reset_mode 0

// 0 for off. 1 for auto. 2 to allow control of a cart's framerate due to host machine's cpu capacity
host_framerate_control 1

// filter splore cartridges
// 0 off 1 on (exclude cartridge tagged as 'mature' by community)
splore_filter 0

// tab display width (1 ~ 4 spaces)
tab_width 1

// 0 off 1 on: draw tab characters as small vertical lines
draw_tabs 0

// 0 off 1 on: record the current cartridge and editor view every 3 seconds (see [appdata]/activity.log.txt)
record_activity_log 0

// 0 off 1 on: allow F6..F9 (alternative: ctrl 6..9)
allow_function_keys 1

// 0 off 1 on: automatically check for a newer version of a BBS cart each time it is run.
check_for_cart_updates 1

// 0 off 1 on: allow access to hardware GPIO at 0x5f80..0x5fff (might need to sudo pico8)
enable_gpio 0

// hide mouse cursor for n seconds when typing.
auto_hide_mouse_cursor 5

// 0 off 1 on: backup with a new timestamped filename on every run
// normally not needed -- was used for debugging crash-on-run
aggressive_backups 0

// back up cartridge in editor every n minutes when not idle (0 for no periodic backups)
periodic_backups 20

// global screen transformations:
// 129 flip horizontally
// 130 flip vertically
// 133 rotate CW 90 degrees
// 134 rotate CW 180 degrees
// 135 rotate CW 270 degrees
transform_screen 134

// 0 off > 1: colour to draw pixel grid in the gfx editor at zoom:8 and zoom:4 (16 for black)
gfx_grid_lines 0

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// add SDL2 game controller mappings to this file
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"customkeys":{
"A":"Z",
"B":"X",
"X":"ESCAPE",
"Y":"D",
"L1":"D",
"L2":"D",
"R1":"D",
"R2":"D",
"LeftDpad":"LEFT",
"RightDpad":"RIGHT",
"UpDpad":"UP",
"DownDpad":"DOWN",
"Start":"RETURN",
"Select":"D",
"Menu":"D"
},
"mouse":{
"scaleFactor":1,
"acceleration":4.0,
"accelerationRate":1.5,
"maxAcceleration":4.0,
"incrementModifier":1.0
},
"performance":{
"cpuclock":1500,
"cpuclockincrement":25,
"maxcpu":1700,
"mincpu":600
},
"bezel":{
"current_bezel":1,
"current_integer_bezel":0,
"bezel_path":"\/mnt\/SDCARD\/RApp\/PICO-8\/res\/bezel\/standard",
"digit_path":"\/mnt\/SDCARD\/RApp\/PICO-8\/res\/digit",
"bezel_int_path":"\/mnt\/SDCARD\/RApp\/PICO-8\/res\/bezel\/integer_scaled"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"label": "Pico-8",
"icon": "/mnt/SDCARD/Icons/Default/rapp/pico-8.png",
"launch": "launch.sh",
"rompath": "../../Roms/PICO",
"imgpath": "../../Roms/PICO",
"useswap": 1,
"shortname": 0,
"hidebios": 1,
"extlist": "p8|png|miyoocmd|pico-8"
}
Loading