Log In  

I am trying to create a script that will run Pico-8 natively on my Anbernic RG35XX Plus.

When I try to get it to run using the pico8_dyn raspi binary I am getting the following error:

SDL Error: SDL not built with haptic (force feedback) support

** FATAL ERROR: Unable to initialize SDL

I've been able to get it to boot, albeit without video, but this is requiring me to build my own version of SDL2, since haptic support is being required by Pico-8 and is not available in the RG35XX native SDL2 system files.

I'd like to avoid having to compile a new version of SDL2 just to "provide haptic support". Is there anything I can do do bypass this requirement in my native SDL2?

Here's my script so far:

#!/bin/bash

# Define variables
SCRIPT_DIR="$(dirname "$0")"
PICO_DIR="$SCRIPT_DIR/pico-8"

# Navigate to the script directory
cd "$SCRIPT_DIR"

# Function to check if a package is installed
is_package_installed() {
    dpkg -l "$1" &> /dev/null
}

# Install dependencies if they are not already installed
if ! is_package_installed wget; then
    apt-get update
    apt-get install -y wget
fi

if ! is_package_installed unzip; then
    apt-get update
    apt-get install -y unzip
fi

# Check if PICO_DIR exists, if not, download and extract Pico-8
if [ ! -d "$PICO_DIR" ]; then
    # Download the PICO-8 zip file
    wget OMITTED THIS URL SINCE IT IS WHERE I AM PULLING MY OFFICIAL PAID FILES FROM

    # Extract the zip file
    unzip pico-8_0.2.6_raspi.zip

    # Delete the zip file
    rm pico-8_0.2.6_raspi.zip
fi

# Navigate to the pico-8 directory
cd "$PICO_DIR"

# Make the pico8 binaries executable
chmod -R +x .

# Execute the pico8 binary and log output
./pico8_dyn -splore -width 640 -height 480 -volume 50 -pixel_perfect 1 -windowed 0 -joystick 0 -home $PICO_DIR -root_path /mnt/sdcard/Roms/PICO8 >> $PICO_DIR/pico8_log.txt 2>&1

If compiling my own version of SDL is my only option, how can I get the video output to work correctly. Right now it outputs in my log:

Current video driver: offscreen

I've tried setting it to directfb, and x11 and such, but it says they are all unavailable. I have a feeling this is because I am compiling the SDL, but I am in a bit over my head in terms of my knowledge of how video drivers work in these kinds of hardware.

P#140769 2024-01-28 22:11 ( Edited 2024-01-28 22:16)

I don't really know how to help right now but I'm following this, I want to run Pico-8 under muOS CFW. I'll report any relevant updates if I have them.

P#140850 2024-01-29 23:47

I've been messing around with MuOS as well. I'll keep you posted if I get it up and running on there as well. Might be easier since it is a wholly different FW. I'll hop on their Discord as well, and maybe we can hash some stuff out there.

P#140923 2024-01-31 14:16

Don't have any programming experience, but if you need help testing, let me know!

P#140932 2024-01-31 16:24

I can see Pico-8 games on RG35xx plus too but it does not play as the control buttons are not working in RetroArch. Some folks told it is played only offline, which still does not make sense.
Any advise will be appreciated.

P#141059 2024-02-03 09:06

@Lengderson the Pico-8 games that are showing in the RG35XX and Plus are being emulated using the Fake08 and Retro8 emulators, which is why they are garbage and don't work well. I am trying to get my legit purchased copy of Pico8 running natively, vs. emulated.

P#141088 2024-02-03 23:55

@SethGeib Thanks. Yes, I do have a legit purchased copy of Pico8, am all for paid games and contribute to the community financially. I just found out that my OS SD card was faulty (that's emulators for you!), managed to pop in another and walah, fake08 (only 39 games) works offline. I don't have a MIM+ to go into Splore to play online, maybe Anbernic might enable that or the next Garlic OS would do, I will be very pleased because at least one of my games platform is legit on a Retrohandheld...haha.

Appreciate if you could keep it posted if you could get Pico8 to run natively.

P#141098 2024-02-04 03:23

The error "FATAL ERROR: Unable to initialize SDL" happens because SDL is probably inited with SDL_INIT_EVERYTHING and well everything (haptic feedback in this case) is not available, you need to rebuild sdl to have it or don't init haptic feedback, since we don't have sources of pico8 your only choice is to rebuild SDL (on stock os) SDL from repo's won't work either they usually require X. SDL2 on batocera etc got patches applied

however it works out of the box on batocera cfw (see https://wiki.batocera.org/systems:pico8#support_for_official_pico-8_engine ) and i have it working under muos 9.1, using batocera libs as SDL2 is currently broken on 9.1 but it will be fixed in v10 which should hit testing soon

pico8_dyn binary is what works. see https://youtu.be/-8sD0AtBIuM

I had another issue on muos though wget could not work with https urls, so i builded my own wget and added a setting for wget so it never verifies certificates as the root certs (ca-certificates) is not installed either on muOS rootfs

P#141360 2024-02-10 10:23 ( Edited 2024-02-10 10:31)

@joyrider, in the code above I am already recompiling SDL2 on the device to get around the haptic restrictions. Can you read back through the whole post and see if you know a way around the issue I am having with the recompile, which is not being able to get video to work correctly. Pico8 boots up and I get sound and no errors, just no audio.

P#141361 2024-02-10 12:18

@SethGeib in short your problem is vanilla SDL2 won't work and batocera and recent test version of muOS use SDL2 patched sources to get some mali video driver to work.

so compiling vanilla SDL2 won't work it will always revert to offscreen video driver as all others don't work or require X or wayland to run. The way (i think) it works on RG35xx-plus/h (at least on recent muos and recent batocera) is SDL2 sources are patched with mali support. i spend this whole morning getting my own build SDL2 lib (with these patches https://github.com/rg35xx-cfw/batocera.linux/tree/master/board/batocera/patches/sdl2 applied to the source) to run but even with the mali support inside it and even when running with LD_LIBRARY_PATH=/path/to/my/sdl2/build/lib/dir SDL_VIDEODRIVER=mali /path/to/pico8_dyn -splore it kept complaining about mali not being available even though there is a /dev/mali device. I think it may also need the maligbm libs but not sure. I know at least if i copied whole lib folder from batocera rootfs (minus libasound) to muos V9.1 that it works but thats like a 300-400 meg folder which is not feasable for a release but if you could figure out what we are missing to get SDL with mali support (which is basically some form of KMSDRM, like how raspberry pi handles these things without X) to work it should work on stockos if using LD_LIBRARY_PATH.

I am also not sure if there was some other mali things added in the rootfs that gets loaded as a module or so but if we / you can figure this out you'll be able to build the required libs to get it to work on stock os

P#141389 2024-02-10 23:26 ( Edited 2024-02-11 00:01)

Yeah, something is definitely weird with wget now on the stock OS as well... it no longer works, nor does curl. So I've resorted to downloading the assets manually and placing them in the correct folders for now (I've commented out the downloads code for now). I am going down the Mali driver path now and have updated my script to install mesa-utils and libgl1-mesa-dri prior to compiling SDL2. Here's my updated script with logging and error checks. It still runs Pico8 after the looooong compile of SDL2 (about 10 mins), but I am still not getting any video. Not sure if I need to specify the driver during the ./configure of SDL or if I need to verbosely set the Driver/Device, or create a window, or what. Not sure what path to take this down...

#!/bin/bash

# Define the log file
LOG_FILE="$(dirname "$0")/Pico8_script_log.txt"

# Function to log a message
log_message() {
    echo "$1" | tee -a "$LOG_FILE"
}

# Function to check and log errors after running a command
check_error() {
    if [ $? -ne 0 ]; then
        log_message "$1"
        exit 1
    fi
}

# Start of the script
log_message "Script started."

# Define variables
SCRIPT_DIR="$(dirname "$0")"
PICO_DIR="$SCRIPT_DIR/pico-8"
PICO_URL="REPLACE THIS WITH YOUR OFFICIAL PICO-8 DOWNLOAD URL"
SDL_VERSION="2.30.0" # SDL version Pico-8 was compiled with
SDL_URL="https://github.com/libsdl-org/SDL/releases/download/release-$SDL_VERSION/SDL2-$SDL_VERSION.tar.gz"
SDL_INSTALL_DIR="$PICO_DIR/sdl"
# Define paths to custom and system libraries
CUSTOM_SDL_PATH="$PICO_DIR/sdl/lib"
SYSTEM_LIB_PATH="/usr/lib:/lib"

log_message "Variables defined."

# Navigate to the script directory
cd "$SCRIPT_DIR" || { log_message "Failed to navigate to script directory."; exit 1; }

# Update package list
apt-get update
check_error "Failed to update package list."

# Function to install or update a package
install_or_update_package() {
    PACKAGE_NAME=$1
    if dpkg -l "$PACKAGE_NAME" &> /dev/null; then
        log_message "$PACKAGE_NAME is already installed. Checking for updates..."
        apt-get install --only-upgrade -y "$PACKAGE_NAME"
        check_error "Failed to update $PACKAGE_NAME."
    else
        log_message "Installing $PACKAGE_NAME..."
        apt-get install -y "$PACKAGE_NAME"
        check_error "Failed to install $PACKAGE_NAME."
    fi
}

# Check and install/update dependencies
install_or_update_package wget
install_or_update_package unzip
install_or_update_package mesa-utils
install_or_update_package libgl1-mesa-dri

log_message "Dependencies checked and updated."

# Check if PICO_DIR exists, if not, download and extract Pico-8
# if [ ! -d "$PICO_DIR" ]; then
#     log_message "Downloading Pico-8..."
#     wget $PICO_URL || { log_message "Failed to download Pico-8."; exit 1; }

#     log_message "Extracting Pico-8..."
#     unzip pico-8_0.2.6_raspi.zip || { log_message "Failed to extract Pico-8."; exit 1; }

#     log_message "Cleaning up Pico-8 setup files..."
#     rm pico-8_0.2.6_raspi.zip || { log_message "Failed to clean up Pico-8 setup files."; exit 1; }
# fi

# log_message "Pico-8 setup."

# Navigate to the pico-8 directory
cd "$PICO_DIR" || { log_message "Failed to navigate to PICO_DIR."; exit 1; }
log_message "Navigated to PICO_DIR."

# Make the pico8 binaries executable
chmod -R +x . || { log_message "Failed to make Pico-8 binaries executable."; exit 1; }
log_message "Pico-8 binaries made executable."

# Check if SDL directory exists and install SDL if not
if [ ! -d "$CUSTOM_SDL_PATH" ]; then
   #log_message "Downloading and installing SDL..."
   #wget $SDL_URL && tar -zxvf SDL2-$SDL_VERSION.tar.gz && rm SDL2-$SDL_VERSION.tar.gz
   #check_error "Failed to download SDL."
   cd SDL2-$SDL_VERSION
   ./configure --prefix=$SDL_INSTALL_DIR && make && make install
   check_error "SDL configure, make, or make install failed."
   cd "$PICO_DIR"
   log_message "SDL installed."
fi

# Set the library path to include your custom SDL path first, then system libraries
export LD_LIBRARY_PATH="$CUSTOM_SDL_PATH:$SYSTEM_LIB_PATH"
log_message "Library path set."

# Execute the pico8_dyn binary and log output
log_message "Starting Pico-8..."
./pico8_dyn -splore -width 640 -height 480 -volume 50 -pixel_perfect 1 -windowed 0 -joystick 0 -home $PICO_DIR -root_path /mnt/sdcard/Roms/PICO8 >> $PICO_DIR/pico8_log.txt 2>&1 || { log_message "Pico-8 failed to start."; exit 1; }

log_message "Script ended."
P#141398 2024-02-11 14:50 ( Edited 2024-02-11 15:02)

@joyrider I've tried applying some of the patches from Batocera to the SDL compile (specifically sdl2_add_video_mali_gles2.patch), but they are failing. Do you know which version of SDL2 these require? I tried 2.28.1 to no avail.

P#141410 2024-02-11 22:43

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-02-22 18:04:54 | 0.098s | Q:24