Commander X16 emulator Install Script
-
Commander X16 Emulator Script
PC - x86/64 it installs fine and can play some games
Raspberry Pi (PI 4 tested) - Got it installed but when i try and run a game it just flashes and goes back to retropi menu so needs further testing.The pi is more than capable of running the emulator fine i believe i just ain't got it to the point games will run unlike PC.
Been fiddling about with Commander X16 emulator on Linux and have a working script for Retropie currently being worked on a tested below.
#!/usr/bin/env bash rp_module_id="x16" rp_module_desc="Commander X16 Emulator" rp_module_help="ROM Extensions: .prg .bin .x16\n\nCopy your Commander X16 programs to \$romdir/x16" rp_module_licence="https://github.com/X16Community/x16-emulator/blob/master/LICENSE" rp_module_repo="git https://github.com/X16Community/x16-emulator.git" rp_module_section="exp" rp_module_flags="dispmanx" function depends_x16() { local depends=(build-essential libsdl2-dev libreadline-dev libpng-dev zlib1g-dev) getDepends "${depends[@]}" } function sources_x16() { gitPullOrClone } function build_x16() { make clean make -j$(nproc) || error "Build failed" if [[ ! -f "$md_build/x16emu" ]]; then error "x16emu binary not found, build might have failed" fi md_ret_require="$md_build/x16emu" } function install_x16() { md_ret_files=( 'x16emu' 'LICENSE' 'README.md' ) cat > "$md_inst/x16-launch.sh" << '_EOF_' #!/bin/bash # Get PRG file (first argument passed to the script) PRG_FILE="$1" # BIOS path resolved using the current user's home BIOS_PATH="$HOME/RetroPie/BIOS/x16/rom.bin" # Check for PRG and ROM existence if [[ -z "$PRG_FILE" ]]; then echo "Usage: $0 path_to_game.prg" >&2 exit 1 fi if [[ ! -f "$BIOS_PATH" ]]; then echo "Missing rom.bin at $BIOS_PATH" >&2 exit 1 fi # Find x16emu binary relative to this script SCRIPT_DIR="$(dirname "$0")" # Launch emulator with ROM and game exec "$SCRIPT_DIR/x16emu" -fullscreen -rom "$BIOS_PATH" -prg "$PRG_FILE" -run _EOF_ chmod +x "$md_inst/x16-launch.sh" } function configure_x16() { mkRomDir "x16" local launch_prefix isPlatform "kms" && launch_prefix="XINIT-WM:" # Create BIOS path if needed if [[ ! -d "$biosdir/x16" ]]; then mkdir -p "$biosdir/x16" fi chown -R $user:$user "$biosdir/x16" if [[ "$md_mode" == "install" ]]; then mkUserDir "$md_conf_root/x16" mkUserDir "$md_conf_root/x16/$md_id" moveConfigFile "$home/.$md_id" "$md_conf_root/x16/$md_id" fi addEmulator 1 "$md_id" "x16" "$launch_prefix$md_inst/x16-launch.sh %ROM%" addSystem "x16" "Commander X16" ".prg .bin .x16" }
So far we have the following with the script
1 - You will need to source the rom.bin file from the following location
https://github.com/commanderx16/x16-rom
I wasn't sure if you can include it in with the emulator or not so so just added the link above. Drop it in Retropie/BIOS/x16 and your good to go.
2 - takes .prg files, .bin, .x16 and even .sdcard images. You will need to make sure all the necessary files for each game such as the .PRG, Bin etc are all in the same directory So if you have a game say Tetris make sure it's a folder called Tetris and inside everything to run that game.
3 - No controllers have been figured out yet
4 - No way of exiting the emulator cleanly has been figured out yet
Screenshots included below
-
@fadingrose Few updates
1 - I removed the simlink and passed through an argument for it to find the rom.bin folder (bios) under BIOS/x16
2 - Games will need to make sure they have all the correct files so ideally you want a folder for each game with all their respective .PRG, .Bin and so fourth inside.Now i just need to work out controllers and how to exit cleanly back to Retropie
-
@fadingrose
Hi, I have been playing around with RetroPie and your script to install the Commander X16 emulator on the system.
I got it working, but unfortunately it runs much to slow to be usable.I had to modify your script a little to get things working. Here is the modified script:
#!/usr/bin/env bash rp_module_id="x16" rp_module_desc="Commander X16 Emulator" rp_module_help="ROM Extensions: .prg .bin .x16\n\nCopy your Commander X16 programs to \$romdir/x16" rp_module_licence="https://github.com/X16Community/x16-emulator/blob/master/LICENSE" rp_module_repo="git https://github.com/X16Community/x16-emulator.git" rp_module_section="exp" rp_module_flags="dispmanx" function depends_x16() { local depends=(build-essential libsdl2-dev libreadline-dev libpng-dev zlib1g-dev) getDepends "${depends[@]}" } function sources_x16() { gitPullOrClone } function build_x16() { make clean make -j$(nproc) || error "Build failed" if [[ ! -f "$md_build/x16emu" ]]; then error "x16emu binary not found, build might have failed" fi md_ret_require="$md_build/x16emu" } function install_x16() { md_ret_files=( 'x16emu' 'LICENSE' 'README.md' ) cat > "$md_inst/x16-launch.sh" << '_EOF_' #!/bin/bash # Get PRG file (first argument passed to the script) PRG_FILE="$1" DIRNAME=$(dirname "$PRG_FILE") SUFFIX=$(basename "$PRG_FILE" | rev | tr '.' ' ' | awk '{print $1}' | rev) # BIOS path resolved using the current user's home BIOS_PATH="$HOME/RetroPie/BIOS/x16/rom.bin" # Check for PRG and ROM existence if [[ -z "$PRG_FILE" ]]; then echo "Usage: $0 path_to_game.prg" >&2 exit 1 fi if [[ ! -f "$BIOS_PATH" ]]; then echo "Missing rom.bin at $BIOS_PATH" >&2 exit 1 fi # Find x16emu binary relative to this script SCRIPT_DIR="$(dirname "$0")" # Launch emulator with ROM and game if [ "$SUFFIX" = "img" ]; then exec "$SCRIPT_DIR/x16emu" -joy1 -joy2 -fullscreen -rom "$BIOS_PATH" -sdcard "$PRG_FILE" -bas "$SCRIPT_DIR/sdlaunch.txt" else exec "$SCRIPT_DIR/x16emu" -joy1 -joy2 -fullscreen -rom "$BIOS_PATH" -fsroot "$DIRNAME" -prg "$PRG_FILE" -run fi _EOF_ cat > "$md_inst/sdlaunch.txt" << '_EOF_' LOAD"*",8 RUN _EOF_ chmod +x "$md_inst/x16-launch.sh" } function configure_x16() { mkRomDir "x16" local launch_prefix isPlatform "kms" && launch_prefix="" # Create BIOS path if needed if [[ ! -d "$biosdir/x16" ]]; then mkdir -p "$biosdir/x16" fi chown -R $user:$user "$biosdir/x16" if [[ "$md_mode" == "install" ]]; then mkUserDir "$md_conf_root/x16" mkUserDir "$md_conf_root/x16/$md_id" moveConfigFile "$home/.$md_id" "$md_conf_root/x16/$md_id" fi addEmulator 1 "$md_id" "x16" "$launch_prefix$md_inst/x16-launch.sh %ROM%" addSystem "x16" "Commander X16" ".prg .bas .basl .img" }
After the Commander X16 emulator had been downloaded, compiled, configured etc. I needed to enter:
RetroPie-Setup -> Configuration/Tools -> backends -> x16
and change it to
using SDL1 on desktop
Some packages related to the x11 window manager were installed and afterwards it seems I can use any of the backend options to launch the emulator.Oh and I have a single gamepad attached to my Pi400 and it works fine with -joy1 and -joy2 added to the commands.
I hope this helps you along your way and maybe you will be able to squeeze out a bit of extra performance of the raspberry pi so the Commander X16 emulator can run at full speed.
-
@JimmyDansbo Fantastic and thank you for the updated script, it installed fine on my test virtual machine under Retropie and my 8bitdo controller just worked without issues and zero configuration. The Raspberry Pi 4 though it installs fine and i dropped in the bios and some games in the relevant location to test but currently battling with my 8bitdo controller as it refuses to connect to the Raspberry Pi. Besides my controller woes though the emulator booted fine and a game ran ok, it was a little sluggish for that specific game but it runs.
I'll give the controller and a few games a full test once i fix that unrelated controller woe
I was looking at countless different solutions for the exit game and now i know that -joy1, -joy2 etc works maybe i can get Retropie to send a signal, command or something to -joy1, -joy2 for someone to press a button combination that will kill the emulator process.
Been side tracked with other projects so i'll figure out my controller issues and get back to testing.
Once the script is fully complete i may get a proper write up guide done for the emulator in PI IE where to put the bios, the games and how they need to be named, stored, controllers and any configurations needed and so on and then hopefully i'll figure out how to get all this info to the Retropie team and see if they eventually get it added properly.
Never sent a request or anything before so don't know the process as of yet
Still this is great progress and it works perfect if i could only exit haha.
-
@fadingrose What would be the "normal" way of exiting from emulating C64 (vice) ?
I have just installed it on my Retro Pi setup and the only way I can figure to exit Vice is to press F12 and then choose quit from the menu. -
@JimmyDansbo I believe with Vice it's the way you described but i ain't played that emulator in a long time due to owning a C64C & TheC64 so no need to use it. I did briefly look at the documentation for the x16 and unless i missed it couldn't figure out how to exit the emulator with the keyboard or find a menu to exit if there even is one.
If it's the case with the x16 not having a menu so they can exit then it will have to be some kind of a key/button mapping to kill it if that would be the case.
-
@fadingrose
I could do a pull request on the emulator to add a key combination to do a clean exit. I am thinking something along the lines of CTRL+X
Would that be helpful in this context?
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.