Moved 'max ROM size' function to more appropriate place.

This commit is contained in:
Stephen Anthony 2020-07-03 14:46:57 -02:30
parent 29fee4c580
commit f0e2b357cf
5 changed files with 10 additions and 7 deletions

View File

@ -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;

View File

@ -48,6 +48,9 @@ class Cartridge : public Device
public:
using StartBankFromPropsFunc = std::function<int()>;
// Maximum size of a ROM cart that Stella can support
static constexpr size_t maxSize() { return 512_KB; }
public:
/**
Create a new cartridge

View File

@ -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<uInt8[]>(BSPF::romMaxSize());
image = make_unique<uInt8[]>(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<size_t>(length, BSPF::romMaxSize());
size = std::min<size_t>(length, Cartridge::maxSize());
in.read(reinterpret_cast<char*>(image.get()), size);
}
else

View File

@ -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<uInt8[]>(BSPF::romMaxSize());
image = make_unique<uInt8[]>(Cartridge::maxSize());
extern uInt32 libretro_read_rom(void* data);
return libretro_read_rom(image.get());

View File

@ -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; }