Skip to content

DuckStation standalone PSX emulator #3486

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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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: 93 additions & 0 deletions scriptmodules/emulators/duckstation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/usr/bin/env bash

# This file is part of The RetroPie Project
#
# The RetroPie Project is the legal property of its developers, whose names are
# too numerous to list here. Please refer to the COPYRIGHT.md file distributed with this source.
#
# See the LICENSE.md file at the top-level directory of this distribution and
# at https://raw.githubusercontent.com/RetroPie/RetroPie-Setup/master/LICENSE.md
#

rp_module_id="duckstation"
rp_module_desc="PlayStation emulator DuckStation"
rp_module_help="ROM Extensions: .pbp .cue .bin .chd .img .ecm .mds .mdf\n\nCopy your PlayStation roms to $romdir/psx\n\nCopy the required BIOS file to $biosdir"
rp_module_licence="GPL3 https://raw.githubusercontent.com/stenzek/duckstation/master/LICENSE"
rp_module_section="exp"
rp_module_flags=""

function depends_duckstation() {
local depends=(cmake libsdl2-dev libsnappy-dev pkg-config libevdev-dev libgbm-dev libdrm-dev)
getDepends "${depends[@]}"
}

function sources_duckstation() {
gitPullOrClone "$md_build" https://github.com/stenzek/duckstation.git
}

function build_duckstation() {
local params=(-DCMAKE_BUILD_TYPE=Release -DENABLE_DISCORD_PRESENCE=OFF -DBUILD_NOGUI_FRONTEND=ON -DBUILD_QT_FRONTEND=OFF)
if isPlatform "x11"; then
params+=(-DUSE_X11=ON)
else
params+=(-DUSE_X11=OFF)
fi
if isPlatform "kms"; then
params+=(-DUSE_DRMKMS=ON)
else
params+=(-DUSE_DRMKMS=OFF)
fi
cmake "${params[@]}" .
make clean
make

md_ret_require="$md_build/bin/duckstation-nogui"
}

function install_duckstation() {
md_ret_files=(
'LICENSE'
'README.md'
'bin'
)
}

function configure_duckstation() {
mkRomDir "psx"

local config="$md_conf_root/psx/duckstation.ini"

addEmulator 0 "$md_id" "psx" "$md_inst/bin/duckstation-nogui -portable -settings $config -- %ROM%"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I recommended will add, for the duckstation-qt build on the X11/wayland platforms.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have an x11 platform to test but for a RetroPie context i would have thought the controller-driven NOGUI front end would be more appropriate more than a mouse-driven one which I presume QT is?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean similar this
addEmulator 1 "$md_id" "psx" "$md_inst/bin/duckstation-nogui -portable -settings $config -- %ROM%"
addEmulator 0 "$md_id" "psx" "$md_inst/bin/duckstation-qt -portable -settings $config -- %ROM%"

https://github.com/stenzek/duckstation/wiki/Command-Line-Arguments

Will needed -fullscreen if you have switch fullscreen Window .

In any case, this would be an alternative option to the no interface and it is the user who chooses which one to use sometimes qt build it's more friendly custom automatic remaps gamepads options than nogui in Desktop Options .

As soon as I have some time I try it on my x86-64 PC or aarch64 platform, which are the devices I have at hand.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, yes that makes sense giving the choice, although as I don't have a device to test this is not something I would want to add in this PR, although please feel free to add it yourself later! :)

addSystem "psx"

[[ "$md_mode" == "remove" ]] && return

# set config defaults
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO the entire config handling should be similar to how we do it in retroarch: create a default file and copy it when it doesn't exist (i.e. on first installs, otherwise it's added with .rp-dist).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree! I think I've done this now

local tmp_config="$(mktemp)"
iniConfig " = " "" "$tmp_config"
if ! grep -q "\[Main\]" "$tmp_config"; then
echo "[Main]" >> "$tmp_config"
fi
# SettingsVersion = 3 stops overwrite of any settings when version number doesn't match
iniSet "SettingsVersion" "3"
if ! grep -q "\[BIOS\]" "$tmp_config"; then
echo "[BIOS]" >> "$tmp_config"
fi
iniSet "SearchDirectory" "$biosdir"
if ! grep -q "\[MemoryCards\]" "$tmp_config"; then
echo "[MemoryCards]" >> "$tmp_config"
fi
iniSet "Directory" "$romdir/psx"
if ! grep -q "\[Display\]" "$tmp_config"; then
echo "[Display]" >> "$tmp_config"
fi
iniSet "LinearFiltering" "false"
iniSet "Directory" "$romdir/psx"
if ! grep -q "\[Hotkeys\]" "$tmp_config"; then
echo "[Hotkeys]" >> "$tmp_config"
fi
iniSet "OpenQuickMenu" "Keyboard/Escape"

copyDefaultConfig "$tmp_config" "$config"
rm "$tmp_config"
}