update bsnes from upstream source

includes some reverts to unnecessary source modifications
This commit is contained in:
Morilli 2024-09-24 14:45:20 +02:00
parent 1231d44afc
commit 117b35f037
14 changed files with 66 additions and 72 deletions

Binary file not shown.

View File

@ -266,6 +266,13 @@ auto SuperFamicom::board() const -> string {
if(headerAddress == 0x40ffb0) mode = "EXHIROM-"; if(headerAddress == 0x40ffb0) mode = "EXHIROM-";
} }
//the Sufami Turbo has the non-descriptive label "ADD-ON BASE CASSETE"
//(yes, missing a T), and its serial "A9PJ" is shared with
//Bishoujo Senshi Sailor Moon SuperS - Fuwafuwa Panic (Japan)
//so we identify it with this embedded string
string sufamiSignature = "BANDAI SFC-ADX";
if (string_view(data.data(), sufamiSignature.length()) == sufamiSignature) board.append("ST-", mode);
//this game's title ovewrites the map mode with '!' (0x21), but is a LOROM game //this game's title ovewrites the map mode with '!' (0x21), but is a LOROM game
if(title() == "YUYU NO QUIZ DE GO!GO") mode = "LOROM-"; if(title() == "YUYU NO QUIZ DE GO!GO") mode = "LOROM-";
@ -274,10 +281,7 @@ auto SuperFamicom::board() const -> string {
bool epsonRTC = false; bool epsonRTC = false;
bool sharpRTC = false; bool sharpRTC = false;
if(serial() == "A9PJ") { if(serial() == "ZBSJ") {
//Sufami Turbo (JPN)
board.append("ST-", mode);
} else if(serial() == "ZBSJ") {
//BS-X: Sore wa Namae o Nusumareta Machi no Monogatari (JPN) //BS-X: Sore wa Namae o Nusumareta Machi no Monogatari (JPN)
board.append("BS-MCC-"); board.append("BS-MCC-");
} else if(serial() == "042J") { } else if(serial() == "042J") {

View File

@ -1,3 +1,5 @@
#include <stdexcept>
#define ConcatenateType(Size) uint##Size##_t #define ConcatenateType(Size) uint##Size##_t
#define DeclareType(Size) ConcatenateType(Size) #define DeclareType(Size) ConcatenateType(Size)

View File

@ -267,6 +267,7 @@ inline auto directory::copy(const string& source, const string& target) -> bool
} }
#else #else
inline auto directoryIsFolder(DIR* dp, struct dirent* ep) -> bool { inline auto directoryIsFolder(DIR* dp, struct dirent* ep) -> bool {
#if defined(PLATFORM_MACOS) || defined(PLATFORM_LINUX) || defined(PLATFORM_BSD)
if(ep->d_type == DT_DIR) return true; if(ep->d_type == DT_DIR) return true;
if(ep->d_type == DT_LNK || ep->d_type == DT_UNKNOWN) { if(ep->d_type == DT_LNK || ep->d_type == DT_UNKNOWN) {
//symbolic links must be resolved to determine type //symbolic links must be resolved to determine type
@ -274,6 +275,15 @@ inline auto directory::copy(const string& source, const string& target) -> bool
fstatat(dirfd(dp), ep->d_name, &sp, 0); fstatat(dirfd(dp), ep->d_name, &sp, 0);
return S_ISDIR(sp.st_mode); return S_ISDIR(sp.st_mode);
} }
#else // strictly POSIX systems
struct stat sp = {0};
stat(ep->d_name, &sp);
if S_ISDIR(sp.st_mode) return true;
if (S_ISLNK(sp.st_mode) || not S_ISREG(sp.st_mode)) {
fstatat(dirfd(dp), ep->d_name, &sp, 0);
return S_ISDIR(sp.st_mode);
}
#endif
return false; return false;
} }

View File

@ -82,6 +82,12 @@ struct inode {
#if defined(PLATFORM_WINDOWS) #if defined(PLATFORM_WINDOWS)
//on Windows, the last status change time (ctime) holds the file creation time instead //on Windows, the last status change time (ctime) holds the file creation time instead
case time::create: return data.st_ctime; case time::create: return data.st_ctime;
#elif defined(__OpenBSD__)
// OpenBSD is a special case that must be handled separately from other BSDs
case time::create: return min((uint)data.__st_birthtime, (uint)data.st_mtime);
#elif defined (__DragonFly__)
// DragonFly BSD does not support file creation time, use modified time instead
case time::create: return data.st_mtime;
#elif defined(PLATFORM_BSD) || defined(PLATFORM_MACOS) #elif defined(PLATFORM_BSD) || defined(PLATFORM_MACOS)
//st_birthtime may return -1 or st_atime if it is not supported by the file system //st_birthtime may return -1 or st_atime if it is not supported by the file system
//the best that can be done in this case is to return st_mtime if it's older //the best that can be done in this case is to return st_mtime if it's older

View File

@ -4,7 +4,7 @@ namespace nall {
using uint = unsigned; using uint = unsigned;
enum class Compiler : uint { Clang, GCC, Microsoft, Unknown }; enum class Compiler : uint { Clang, GCC, Microsoft, Unknown };
enum class Platform : uint { Windows, MacOS, Linux, BSD, Android, Unknown }; enum class Platform : uint { Windows, MacOS, Linux, BSD, Haiku, Android, Unknown };
enum class API : uint { Windows, Posix, Unknown }; enum class API : uint { Windows, Posix, Unknown };
enum class DisplayServer : uint { Windows, Quartz, Xorg, Unknown }; enum class DisplayServer : uint { Windows, Quartz, Xorg, Unknown };
enum class Architecture : uint { x86, amd64, ARM32, ARM64, PPC32, PPC64, Unknown }; enum class Architecture : uint { x86, amd64, ARM32, ARM64, PPC32, PPC64, Unknown };
@ -98,13 +98,20 @@ namespace nall {
constexpr auto platform() -> Platform { return Platform::Linux; } constexpr auto platform() -> Platform { return Platform::Linux; }
constexpr auto api() -> API { return API::Posix; } constexpr auto api() -> API { return API::Posix; }
constexpr auto display() -> DisplayServer { return DisplayServer::Xorg; } constexpr auto display() -> DisplayServer { return DisplayServer::Xorg; }
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined (__DragonFly__)
#define PLATFORM_BSD #define PLATFORM_BSD
#define API_POSIX #define API_POSIX
#define DISPLAY_XORG #define DISPLAY_XORG
constexpr auto platform() -> Platform { return Platform::BSD; } constexpr auto platform() -> Platform { return Platform::BSD; }
constexpr auto api() -> API { return API::Posix; } constexpr auto api() -> API { return API::Posix; }
constexpr auto display() -> DisplayServer { return DisplayServer::Xorg; } constexpr auto display() -> DisplayServer { return DisplayServer::Xorg; }
#elif defined(__HAIKU__)
#define PLATFORM_HAIKU
#define API_POSIX
#define DISPLAY_UNKNOWN
constexpr auto platform() -> Platform { return Platform::Haiku; }
constexpr auto api() -> API { return API::Posix; }
constexpr auto display() -> DisplayServer { return DisplayServer::Unknown; }
#else #else
#warning "unable to detect platform" #warning "unable to detect platform"
#define PLATFORM_UNKNOWN #define PLATFORM_UNKNOWN

View File

@ -169,16 +169,6 @@ template<uint Bits> struct stringify<Real<Bits>> {
//arrays //arrays
template<> struct stringify<vector<uint8_t>> { template<> struct stringify<vector<uint8_t>> {
stringify(vector<uint8_t> source) {
_text.resize(source.size());
memory::copy(_text.data(), source.data(), source.size());
}
auto data() const -> const char* { return _text.data(); }
auto size() const -> uint { return _text.size(); }
vector<char> _text;
};
template<> struct stringify<const vector<uint8_t>&> {
stringify(const vector<uint8_t>& source) { stringify(const vector<uint8_t>& source) {
_text.resize(source.size()); _text.resize(source.size());
memory::copy(_text.data(), source.data(), source.size()); memory::copy(_text.data(), source.data(), source.size());
@ -191,7 +181,7 @@ template<> struct stringify<const vector<uint8_t>&> {
//char arrays //char arrays
template<> struct stringify<char*> { template<> struct stringify<char*> {
stringify(char* source) : _data(source ? source : "") {} stringify(const char* source) : _data(source ? source : "") {}
auto data() const -> const char* { return _data; } auto data() const -> const char* { return _data; }
auto size() const -> uint { return strlen(_data); } auto size() const -> uint { return strlen(_data); }
const char* _data; const char* _data;
@ -213,13 +203,6 @@ template<> struct stringify<string> {
const string& _text; const string& _text;
}; };
template<> struct stringify<const string&> {
stringify(const string& source) : _text(source) {}
auto data() const -> const char* { return _text.data(); }
auto size() const -> uint { return _text.size(); }
const string& _text;
};
template<> struct stringify<string_view> { template<> struct stringify<string_view> {
stringify(const string_view& source) : _view(source) {} stringify(const string_view& source) : _view(source) {}
auto data() const -> const char* { return _view.data(); } auto data() const -> const char* { return _view.data(); }
@ -227,13 +210,6 @@ template<> struct stringify<string_view> {
const string_view& _view; const string_view& _view;
}; };
template<> struct stringify<const string_view&> {
stringify(const string_view& source) : _view(source) {}
auto data() const -> const char* { return _view.data(); }
auto size() const -> uint { return _view.size(); }
const string_view& _view;
};
template<> struct stringify<array_view<uint8_t>> { template<> struct stringify<array_view<uint8_t>> {
stringify(const array_view<uint8_t>& source) : _view(source) {} stringify(const array_view<uint8_t>& source) : _view(source) {}
auto data() const -> const char* { return _view.data<const char>(); } auto data() const -> const char* { return _view.data<const char>(); }
@ -241,13 +217,6 @@ template<> struct stringify<array_view<uint8_t>> {
const array_view<uint8_t>& _view; const array_view<uint8_t>& _view;
}; };
template<> struct stringify<const array_view<uint8_t>&> {
stringify(const array_view<uint8_t>& source) : _view(source) {}
auto data() const -> const char* { return _view.data<const char>(); }
auto size() const -> uint { return _view.size(); }
const array_view<uint8_t>& _view;
};
template<> struct stringify<string_pascal> { template<> struct stringify<string_pascal> {
stringify(const string_pascal& source) : _text(source) {} stringify(const string_pascal& source) : _text(source) {}
auto data() const -> const char* { return _text.data(); } auto data() const -> const char* { return _text.data(); }
@ -255,13 +224,6 @@ template<> struct stringify<string_pascal> {
const string_pascal& _text; const string_pascal& _text;
}; };
template<> struct stringify<const string_pascal&> {
stringify(const string_pascal& source) : _text(source) {}
auto data() const -> const char* { return _text.data(); }
auto size() const -> uint { return _text.size(); }
const string_pascal& _text;
};
//pointers //pointers
//note: T = char* is matched by stringify<string_view> //note: T = char* is matched by stringify<string_view>
@ -281,8 +243,8 @@ template<typename T> struct stringify<T*> {
// //
template<typename T> auto make_string(T value) -> stringify<T> { template<typename T> auto make_string(const T& value) {
return stringify<T>(forward<T>(value)); return stringify<std::decay_t<T>>(value);
} }
} }

View File

@ -6,10 +6,8 @@
#undef UNICODE #undef UNICODE
#undef WINVER #undef WINVER
#undef WIN32_LEAN_AND_LEAN #undef WIN32_LEAN_AND_MEAN
#undef _WIN32_WINNT #undef _WIN32_WINNT
#undef _WIN32_IE
#undef __MSVCRT_VERSION__
#undef NOMINMAX #undef NOMINMAX
#undef PATH_MAX #undef PATH_MAX
@ -17,8 +15,6 @@
#define WINVER 0x0601 #define WINVER 0x0601
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#define _WIN32_WINNT WINVER #define _WIN32_WINNT WINVER
#define _WIN32_IE WINVER
#define __MSVCRT_VERSION__ WINVER
#define NOMINMAX #define NOMINMAX
#define PATH_MAX 260 #define PATH_MAX 260

View File

@ -24,7 +24,7 @@ namespace SameBoy {
static auto joyp_write(GB_gameboy_t*, uint8_t value) -> void { static auto joyp_write(GB_gameboy_t*, uint8_t value) -> void {
bool p14 = value & 0x10; bool p14 = value & 0x10;
bool p15 = value & 0x20; bool p15 = value & 0x20;
if (!p14 || !p15) platform->notify("NO_LAG_SGB"); if (!p14 || !p15) platform->notify("NO_LAG_SGB");
icd.joypWrite(p14, p15); icd.joypWrite(p14, p15);
} }
@ -45,6 +45,9 @@ namespace SameBoy {
static auto vblank(GB_gameboy_t*, GB_vblank_type_t) -> void { static auto vblank(GB_gameboy_t*, GB_vblank_type_t) -> void {
} }
static auto log(GB_gameboy_t *gb, const char *string, GB_log_attributes attributes) -> void {
}
} }
auto ICD::synchronizeCPU() -> void { auto ICD::synchronizeCPU() -> void {
@ -100,6 +103,7 @@ auto ICD::load() -> bool {
GB_set_rgb_encode_callback(&sameboy, &SameBoy::rgb_encode); GB_set_rgb_encode_callback(&sameboy, &SameBoy::rgb_encode);
GB_apu_set_sample_callback(&sameboy, &SameBoy::sample); GB_apu_set_sample_callback(&sameboy, &SameBoy::sample);
GB_set_vblank_callback(&sameboy, &SameBoy::vblank); GB_set_vblank_callback(&sameboy, &SameBoy::vblank);
GB_set_log_callback(&sameboy, &SameBoy::log);
GB_set_pixels_output(&sameboy, &bitmap[0]); GB_set_pixels_output(&sameboy, &bitmap[0]);
if(auto loaded = platform->load(ID::GameBoy, "Game Boy", "gb")) { if(auto loaded = platform->load(ID::GameBoy, "Game Boy", "gb")) {
information.pathID = loaded.pathID; information.pathID = loaded.pathID;

View File

@ -24,6 +24,7 @@ auto SA1::IRAM::readCPU(uint address, uint8 data) -> uint8 {
auto SA1::IRAM::writeCPU(uint address, uint8 data) -> void { auto SA1::IRAM::writeCPU(uint address, uint8 data) -> void {
cpu.synchronizeCoprocessors(); cpu.synchronizeCoprocessors();
if(!(sa1.mmio.siwp & 1 << (address >> 8 & 7))) return;
return write(address, data); return write(address, data);
} }
@ -32,5 +33,6 @@ auto SA1::IRAM::readSA1(uint address, uint8 data) -> uint8 {
} }
auto SA1::IRAM::writeSA1(uint address, uint8 data) -> void { auto SA1::IRAM::writeSA1(uint address, uint8 data) -> void {
if(!(sa1.mmio.ciwp & 1 << (address >> 8 & 7))) return;
return write(address, data); return write(address, data);
} }

View File

@ -1,18 +1,14 @@
struct ProtectableMemory : Memory { struct ProtectableMemory : Memory {
inline auto reset() -> void override { inline auto reset() -> void override {
//delete[] self.data; delete[] self.data;
//self.data = nullptr; self.data = nullptr;
//self.size = 0; self.size = 0;
} }
inline auto allocate(uint size, uint8 fill = 0xff) -> void override { inline auto allocate(uint size, uint8 fill = 0xff) -> void override {
if (!self.data) {
self.data = alloc_plain<uint8>(self.size = size);
}
if(self.size != size) { if(self.size != size) {
//delete[] self.data; delete[] self.data;
//self.data = new uint8[self.size = size]; self.data = new uint8[self.size = size];
abort();
} }
for(uint address : range(size)) { for(uint address : range(size)) {
self.data[address] = fill; self.data[address] = fill;

View File

@ -1,18 +1,14 @@
struct WritableMemory : Memory { struct WritableMemory : Memory {
inline auto reset() -> void override { inline auto reset() -> void override {
//delete[] self.data; delete[] self.data;
//self.data = nullptr; self.data = nullptr;
//self.size = 0; self.size = 0;
} }
inline auto allocate(uint size, uint8 fill = 0xff) -> void override { inline auto allocate(uint size, uint8 fill = 0xff) -> void override {
if (!self.data) {
self.data = alloc_plain<uint8>(self.size = size);
}
if(self.size != size) { if(self.size != size) {
//delete[] self.data; delete[] self.data;
//self.data = new uint8[self.size = size]; self.data = new uint8[self.size = size];
abort();
} }
for(uint address : range(size)) { for(uint address : range(size)) {
self.data[address] = fill; self.data[address] = fill;

View File

@ -4,7 +4,7 @@ uint PPU::Line::count = 0;
auto PPU::Line::flush() -> void { auto PPU::Line::flush() -> void {
if(Line::count) { if(Line::count) {
if(ppu.hdScale() > 1) cacheMode7HD(); if(ppu.hdScale() > 1) cacheMode7HD();
// #pragma omp parallel for if(Line::count >= 8) // we do not have openmp support in waterbox #pragma omp parallel for if(Line::count >= 8)
for(uint y = 0; y < Line::count; y++) { for(uint y = 0; y < Line::count; y++) {
if(ppu.deinterlace()) { if(ppu.deinterlace()) {
if(!ppu.interlace()) { if(!ppu.interlace()) {

View File

@ -15,6 +15,12 @@ auto System::run() -> void {
} }
auto System::runToSave() -> void { auto System::runToSave() -> void {
// Enable coprocessor delayed sync if it is off - this is extremely important
// for coprocessor games, as many will not sync correctly for states when the
// option is off.
bool delay_sync_prev = configuration.hacks.coprocessor.delayedSync;
configuration.hacks.coprocessor.delayedSync = true;
auto method = configuration.system.serialization.method; auto method = configuration.system.serialization.method;
//these games will periodically deadlock when using "Fast" synchronization //these games will periodically deadlock when using "Fast" synchronization
@ -30,6 +36,9 @@ auto System::runToSave() -> void {
scheduler.mode = Scheduler::Mode::Run; scheduler.mode = Scheduler::Mode::Run;
scheduler.active = cpu.thread; scheduler.active = cpu.thread;
// Restore coprocessor delayed sync to whatever it was previous to the state save operation
configuration.hacks.coprocessor.delayedSync = delay_sync_prev;
} }
auto System::runToSaveFast() -> void { auto System::runToSaveFast() -> void {