mirror of https://github.com/stella-emu/stella.git
Move 'max rom size' into a const method, and make use of it elsewhere in the code.
This commit is contained in:
parent
6869582d5a
commit
ad781da69d
|
@ -90,9 +90,9 @@ using DWordBuffer = std::unique_ptr<uInt32[]>; // NOLINT
|
||||||
using AdjustFunction = std::function<void(int)>;
|
using AdjustFunction = std::function<void(int)>;
|
||||||
|
|
||||||
// We use KB a lot; let's make a literal for it
|
// We use KB a lot; let's make a literal for it
|
||||||
constexpr uInt32 operator "" _KB(unsigned long long size)
|
constexpr size_t operator "" _KB(unsigned long long size)
|
||||||
{
|
{
|
||||||
return static_cast<uInt32>(size * 1024);
|
return static_cast<size_t>(size * 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const string EmptyString("");
|
static const string EmptyString("");
|
||||||
|
@ -128,6 +128,9 @@ namespace BSPF
|
||||||
static const string ARCH = "NOARCH";
|
static const string ARCH = "NOARCH";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Maximum size of a ROM that Stella can support
|
||||||
|
inline constexpr size_t romMaxSize() { return 512_KB; }
|
||||||
|
|
||||||
// Make 2D-arrays using std::array less verbose
|
// Make 2D-arrays using std::array less verbose
|
||||||
template<typename T, size_t ROW, size_t COL>
|
template<typename T, size_t ROW, size_t COL>
|
||||||
using array2D = std::array<std::array<T, COL>, ROW>;
|
using array2D = std::array<std::array<T, COL>, ROW>;
|
||||||
|
|
|
@ -83,7 +83,7 @@ uInt16 Cartridge::bankSize(uInt16 bank) const
|
||||||
|
|
||||||
getImage(size);
|
getImage(size);
|
||||||
|
|
||||||
return std::min(uInt32(size) / romBankCount(), 4_KB); // assuming that each bank has the same size
|
return std::min(size / romBankCount(), 4_KB); // assuming that each bank has the same size
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -236,7 +236,7 @@ size_t FilesystemNode::read(ByteBuffer& image) const
|
||||||
return size;
|
return size;
|
||||||
|
|
||||||
// Otherwise, the default behaviour is to read from a normal C++ ifstream
|
// Otherwise, the default behaviour is to read from a normal C++ ifstream
|
||||||
image = make_unique<uInt8[]>(512 * 1024);
|
image = make_unique<uInt8[]>(BSPF::romMaxSize());
|
||||||
ifstream in(getPath(), std::ios::binary);
|
ifstream in(getPath(), std::ios::binary);
|
||||||
if (in)
|
if (in)
|
||||||
{
|
{
|
||||||
|
@ -247,7 +247,7 @@ size_t FilesystemNode::read(ByteBuffer& image) const
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
throw runtime_error("Zero-byte file");
|
throw runtime_error("Zero-byte file");
|
||||||
|
|
||||||
size = std::min<size_t>(length, 512 * 1024);
|
size = std::min<size_t>(length, BSPF::romMaxSize());
|
||||||
in.read(reinterpret_cast<char*>(image.get()), size);
|
in.read(reinterpret_cast<char*>(image.get()), size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue