A Rust and egui based front-end for the SwanStation PS1 Libretro core
  • C++ 58.4%
  • C 36.7%
  • Rust 2.2%
  • HLSL 0.7%
  • GLSL 0.6%
  • Other 1.2%
Find a file
LibretroAdmin 6acddfd1d8 core/cheats: remove dead code unreachable from the libretro frontend
This file was forked from Duckstation, which has a full Qt+ImGui
cheat-manager UI (file-format loaders, a memory scanner, a
watch list, type/activation name tables, code groups, master
enable, etc.). swanstation only exposes cheats through the
libretro retro_cheat_set / retro_cheat_reset entry points, and
that flow needs a much smaller surface area than the
Qt-targeted API supplies. The unused code never reaches a
caller in this tree.

Audited the entire src/ directory; the libretro-reachable cheat
API is exactly:

  CheatList()                              ctor   from libretro_host_interface
  ~CheatList()                             dtor   from libretro_host_interface
  CheatList::SetCode(uint32_t, CheatCode)         from libretro_host_interface:981
  CheatList::Apply()                              from system.cpp:1188
  CheatList::ParseLibretroCheat(...)       static from libretro_host_interface:978
  CheatList::ResetSharedScratchRegisters() static from system.cpp
  CheatCode::Apply()                              from CheatList::Apply (internal)
  CheatCode::GetNextNonConditionalInstruction()   from CheatCode::Apply (internal)
  CheatCode::Valid()                              kept (cheap, plausible future use)

Removed from cheats.h:

  CheatCode::Type enum + value Gameshark
  CheatCode::Activation enum + values Manual/EndFrame
  CheatCode fields:  group, comments, type, activation
  CheatCode methods: IsManuallyActivated,
                     GetInstructionsAsString,
                     SetInstructionsFromString,
                     ApplyOnDisable,
                     GetTypeName/GetTypeDisplayName/ParseTypeName,
                     GetActivationName/GetActivationDisplayName/ParseActivationName
  CheatList::Format enum + values Autodetect/PCSXR/Libretro/EPSXe/Count
  CheatList methods: GetCode (both overloads),
                     GetCodeCount, IsCodeEnabled,
                     GetMasterEnable, SetMasterEnable,
                     FindCode (both overloads),
                     AddCode, RemoveCode,
                     GetEnabledCodeCount, GetCodeGroups,
                     EnableCode, DisableCode, SetCodeEnabled,
                     LoadFromPCSXRString,
                     LoadFromLibretroString,
                     LoadFromEPSXeString,
                     ApplyCode,
                     MergeList
  CheatList field:   m_master_enable
  Classes:           MemoryScan (entire class, including
                     Operator enum, Result struct, ResultVector
                     alias, accessors and search/update methods)
                     MemoryWatchList (entire class, including
                     Entry struct, EntryVector alias, accessors,
                     entry mutation, and freeze handling)
  Include:           <optional> (was only needed for
                     ParseTypeName / ParseActivationName
                     return types)

Removed from cheats.cpp:

  static helpers:    IsHexCharacter, SignedCharToInt, FindKey,
                     KeyValuePairVector alias - all three were
                     only used by the format-loader methods above
  CheatList method bodies for everything dropped from cheats.h
  CheatCode method bodies for everything dropped from cheats.h
  m_master_enable check inside Apply() (the field had no
  setter outside the now-dead SetMasterEnable accessor, so
  default-true was the only value it ever held and the
  'if (!m_master_enable) return;' guard was a constant-false
  branch)
  Static arrays:     s_cheat_code_type_names,
                     s_cheat_code_type_display_names,
                     s_cheat_code_activation_names,
                     s_cheat_code_activation_display_names
                     and their TRANSLATABLE wrappers - all four
                     only fed the Get*Name methods that are gone
  MemoryScan and MemoryScan::Result method bodies
  MemoryWatchList method bodies
  Unused includes:   common/byte_stream.h
                     common/string.h
                     common/string_util.h
                     core/host_interface.h
                     <cctype>
                     <iomanip>
                     <sstream>

Behaviour preserved:
  - retro_cheat_set / retro_cheat_reset paths unchanged.
  - System::Shutdown still calls CheatList::ResetSharedScratchRegisters
    via the unique_ptr<CheatList> path; the static cht_register
    array and its fill(0) are unchanged.
  - CheatCode::Apply and GetNextNonConditionalInstruction (the
    GameShark interpreter, ~1200 lines including the giant
    instruction switch) are completely untouched.

Diff:
  src/core/cheats.h:   315 -> 127 lines (-188, -60%)
  src/core/cheats.cpp: 3011 -> 1942 lines (-1069, -35%)
  Total:              -1257 lines

Build: Makefile.libretro platform=unix - clean, no warnings.
swanstation_libretro.so size: 8020336 -> 7965960 bytes
(-54376, roughly the eight removed static name/display-name
tables, the MemoryScan / MemoryWatchList method bodies, the
file-format loaders and their stringstream machinery, and the
inlined dead branches that survive in -O3 builds).
retro_* exports: 25 (unchanged).
2026-05-14 15:42:17 +02:00
CMakeModules Remove unused files 2023-03-25 17:43:35 +01:00
dep Make OpenBIOS a built-in fallback. 2026-03-28 10:43:30 +00:00
src core/cheats: remove dead code unreachable from the libretro frontend 2026-05-14 15:42:17 +02:00
.clang-format clang-format: Enable brace wrapping after case label 2020-01-24 14:49:43 +10:00
.gitattributes Initial commit 2019-09-11 14:00:42 +10:00
.gitignore Sync Android strings 2021-07-17 20:14:40 +10:00
.gitlab-ci.yml Merge pull request #167 from cscd98/webos-ci 2026-04-10 05:12:17 +02:00
CMakeLists.txt build: add MSB_FIRST opt-in flag for big-endian hosts 2026-05-08 00:32:03 +02:00
libretro.osx.def libretro: add static Makefile.libretro build 2026-05-07 21:32:02 +02:00
LICENSE Initial commit 2019-09-11 14:00:42 +10:00
link.T libretro: add static Makefile.libretro build 2026-05-07 21:32:02 +02:00
Makefile.libretro audio: devirtualize AudioStream, fold NullAudioStream into LibretroAudioStream 2026-05-08 15:07:36 +02:00
README.md Documentation OpenBIOS usage in the README. 2026-04-02 10:46:10 +01:00
TODO Update TODO (#132) 2025-01-17 16:28:45 +01:00

SwanStation - PlayStation 1, aka. PSX Emulator

Features | System Requirements | Disclaimers

SwanStation is a hard fork and open-source Libretro core implementation of DuckStation, which is an emulator of the Sony PlayStation(TM) console, focusing on playability, speed, and long-term maintainability. The goal is to be as accurate as possible while maintaining performance suitable for low-end devices. "Hack" options are discouraged, the default configuration should support all playable games with only some of the enhancements having compatibility issues.

A "BIOS" ROM image can be used, but is not required. You can use an image from any hardware version or region, although mismatching game regions and BIOS regions may have compatibility issues. A ROM image is not provided with the emulator for legal reasons, you should dump this from your own console using Caetla or other means. If no ROM image is provided, OpenBIOS will be used instead.

Features

SwanStation features include:

  • CPU Recompiler/JIT (x86-64, armv7/AArch32 and AArch64)
  • Hardware (D3D11, OpenGL, Vulkan) and software rendering
  • Upscaling, texture filtering, and true colour (24-bit) in hardware renderers
  • PGXP for geometry precision, texture correction, and depth buffer emulation
  • Adaptive downsampling filter
  • Post processing shader chains
  • "Fast boot" for skipping BIOS splash/intro
  • Save state support
  • Supports bin/cue images, raw bin/img files, MAME CHD, single-track ECM, MDS/MDF, and unencrypted PBP formats.
  • Direct booting of homebrew executables
  • Direct loading of Portable Sound Format (psf) files
  • Digital and analog controllers for input (rumble is forwarded to host)
  • Namco GunCon lightgun support (simulated with mouse)
  • NeGcon support
  • Emulated CPU overclocking
  • Multitap controllers (up to 8 devices)
  • RetroAchievements
  • Automatic loading/applying of PPF patches

System Requirements

  • A CPU faster than a potato. But it needs to be x86_64, AArch32/armv7, or AArch64/ARMv8, otherwise you won't get a recompiler and it'll be slow.
  • For the hardware renderers, a GPU capable of OpenGL 3.1/OpenGL ES 3.0/Direct3D 11 Feature Level 10.0 (or Vulkan 1.0) and above. So, basically anything made in 2013 or later.

Region detection and BIOS images

By default, SwanStation will emulate the region check present in the CD-ROM controller of the console. This means that when the region of the console does not match the disc, it will refuse to boot, giving a "Please insert PlayStation CD-ROM" message. SwanStation supports automatic detection disc regions, and if you set the console region to auto-detect as well, this should never be a problem.

The region checking can be disabled in the console options tab. This is the only way to play unlicensed games or homebrew which does not supply a correct region string on the disc, aside from using fastboot which skips the check entirely.

Mismatching the disc and console regions with the check disabled is supported, but may break games if they are patching the BIOS and expecting specific content.

LibCrypt protection and SBI files

A number of PAL region games use LibCrypt protection, requiring additional CD subchannel information to run properly. libcrypt not functioning usually manifests as hanging or crashing, but can sometimes affect gameplay too, depending on how the game implemented it.

For these games, make sure that the CD image and its corresponding SBI (.sbi) file have the same name and are placed in the same directory. SwanStation will automatically load the SBI file when it is found next to the CD image.

For example, if your disc image was named Spyro3.cue, you would place the SBI file in the same directory, and name it Spyro3.sbi.

Tests

  • Passes amidog's CPU and GTE tests in both interpreter and recompiler modes, partial passing of CPX tests

Disclaimers

"PlayStation" and "PSX" are registered trademarks of Sony Interactive Entertainment Europe Limited. This project is not affiliated in any way with Sony Interactive Entertainment.