diff --git a/src/common/bspf.hxx b/src/common/bspf.hxx index a887bf80a..5201ef2ff 100644 --- a/src/common/bspf.hxx +++ b/src/common/bspf.hxx @@ -128,9 +128,6 @@ namespace BSPF static const string ARCH = "NOARCH"; #endif - // Maximum size of a ROM that Stella can support - inline constexpr size_t romMaxSize() { return 512_KB; } - // Get next power of two greater than or equal to the given value inline size_t nextPowerOfTwo(size_t size) { if(size < 2) return 1; diff --git a/src/emucore/Cart.hxx b/src/emucore/Cart.hxx index 8ccd10d79..8a2e4656e 100644 --- a/src/emucore/Cart.hxx +++ b/src/emucore/Cart.hxx @@ -48,6 +48,9 @@ class Cartridge : public Device public: using StartBankFromPropsFunc = std::function; + // Maximum size of a ROM cart that Stella can support + static constexpr size_t maxSize() { return 512_KB; } + public: /** Create a new cartridge diff --git a/src/emucore/FSNode.cxx b/src/emucore/FSNode.cxx index 0d9e53ad1..e9da05b03 100644 --- a/src/emucore/FSNode.cxx +++ b/src/emucore/FSNode.cxx @@ -18,6 +18,7 @@ // Copyright (C) 2002-2004 The ScummVM project //============================================================================ +#include "Cart.hxx" #include "FSNodeFactory.hxx" #include "FSNode.hxx" @@ -237,7 +238,7 @@ size_t FilesystemNode::read(ByteBuffer& image) const return size; // Otherwise, the default behaviour is to read from a normal C++ ifstream - image = make_unique(BSPF::romMaxSize()); + image = make_unique(Cartridge::maxSize()); ifstream in(getPath(), std::ios::binary); if (in) { @@ -248,7 +249,7 @@ size_t FilesystemNode::read(ByteBuffer& image) const if (length == 0) throw runtime_error("Zero-byte file"); - size = std::min(length, BSPF::romMaxSize()); + size = std::min(length, Cartridge::maxSize()); in.read(reinterpret_cast(image.get()), size); } else diff --git a/src/libretro/FSNodeLIBRETRO.cxx b/src/libretro/FSNodeLIBRETRO.cxx index 8c242391b..f3670f0a2 100644 --- a/src/libretro/FSNodeLIBRETRO.cxx +++ b/src/libretro/FSNodeLIBRETRO.cxx @@ -16,6 +16,7 @@ //============================================================================ #include "bspf.hxx" +#include "Cart.hxx" #include "FSNodeLIBRETRO.hxx" #ifdef _WIN32 @@ -93,7 +94,7 @@ AbstractFSNodePtr FilesystemNodeLIBRETRO::getParent() const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - size_t FilesystemNodeLIBRETRO::read(ByteBuffer& image) const { - image = make_unique(BSPF::romMaxSize()); + image = make_unique(Cartridge::maxSize()); extern uInt32 libretro_read_rom(void* data); return libretro_read_rom(image.get()); diff --git a/src/libretro/StellaLIBRETRO.hxx b/src/libretro/StellaLIBRETRO.hxx index 01c2cbaf7..b3d87725b 100644 --- a/src/libretro/StellaLIBRETRO.hxx +++ b/src/libretro/StellaLIBRETRO.hxx @@ -21,6 +21,7 @@ #include "bspf.hxx" #include "OSystemLIBRETRO.hxx" +#include "Cart.hxx" #include "Console.hxx" #include "ConsoleTiming.hxx" #include "Control.hxx" @@ -59,7 +60,7 @@ class StellaLIBRETRO void* getROM() const { return rom_image.get(); } uInt32 getROMSize() const { return rom_size; } - constexpr uInt32 getROMMax() const { return BSPF::romMaxSize(); } + constexpr uInt32 getROMMax() const { return Cartridge::maxSize(); } uInt8* getRAM() { return system_ram; } constexpr uInt32 getRAMSize() const { return 128; }