Previously, the emulator would mysteriously fail if the user did not
know beforehand to provide a copy of the BIOS. This avoids that
problem, silently and automatically loading a built-in copy of
OpenBIOS, so that the emulator will always do what the user wants:
boot the game.
Closes#153. Requested in #158.
Now uses libchdr's own CMake script instead of a custom one, which
allows for assembly-optimised LZMA decoding on some platforms.
This update also introduces support for Zstandard compression.
The lack of this was causing a build error when compiling with MSYS2 MinGW Clang x64.
There were other build errors too, but those were caused by `offsetof` somehow not being constexpr, which I imagine is a Clang/MSYS2 bug.
Don't look for BIOS files in the same directory as the executable,
instead obey the libretro system directory.
```cpp
if (!g_retro_environment_callback(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &system_directory) || !system_directory)
return GetProgramDirectoryRelativePath("system");
```
The code above reads "If we can't get the system directory from
libretro, return a directory named `system` located in the same
directory as the executable containing main()". This code is only used
to look for the path with the BIOS files.
On Unix, If RetroArch is /usr/bin/retroarch (or equivalent), it will try
to look for BIOS files at /usr/bin/system. On Android, non-root programs
will always be unable to look at that directory. Other platforms will
display similarly strange behavior.
This behavior feels more like an accident than an intentional design
choice. This commit removes it and all the code that implements it.
ANDROID is defined by the NDK
__ANDROID__ is defined by the compiler.
When compiling for android without the NDK, such as inside Termux,
ANDROID isn't defined.
POSIX guarantees that off_t is a signed integer type. It was typically
int32_t on historical versions of implementations. Some kind of
migration is necessary for platforms that started with int32_t, and
glibc did it the worst way possible: 32-bit platforms still default to
32-bit off_t, they added a _FILE_OFFSET_BITS macro to request a specific
size, and you can alternatively call nonstandard versions of standard
functions that work with off_t which use a specific size, these are
typically suffixed with "64" (e.g. ftruncate64, stat64) and work with a
nonstandard off64_t type.
Swanstation gets this confusing situation wrong by both defining
_FILE_OFFSET_BITS=64 and using the nonstandard .*64 functions on Linux.
This works on glibc, but breaks other libcs such as musl. By using the
standard names and letting _FILE_OFFSET_BITS handle the rest on glibc,
the code works on all Linux systems.
Ref: https://www.gnu.org/software/libc/manual/html_node/File-Size.html#index-ftruncate64
In file included from /home/jan/Work/swanstation/src/core/bus.cpp:6:
In file included from /home/jan/Work/swanstation/src/core/cpu_code_cache.h:14:
/home/jan/Work/swanstation/src/core/cpu_recompiler_types.h:70:37: error: integer value 16 is outside the valid range of values [0, 15] for the enumeration type 'Code' [-Wenum-constexpr-conver
sion]
70 | constexpr HostReg HostReg_Invalid = static_cast<HostReg>(HostReg_Count);
| ^
2 warnings and 1 error generated.
The code was unspecified behavior in C++ prior to C++17, and was changed
to undefined behavior in C++17. Recent versions of Clang have added a
warning that is treated as an error by default for it, and this commit
fixes compilation on recent Clang.
Ref: https://wiki.sei.cmu.edu/confluence/display/cplusplus/INT50-CPP.+Do+not+cast+to+an+out-of-range+enumeration+value
Ref: https://releases.llvm.org/18.1.4/tools/clang/docs/DiagnosticsReference.html#wenum-constexpr-conversion