Make sure 3E+ ROMs are always internally sized as a multiple 1024 bytes.

This commit is contained in:
Stephen Anthony 2020-06-09 12:32:14 -02:30
parent 476a2b2c56
commit e497405216
2 changed files with 7 additions and 1 deletions

View File

@ -140,6 +140,12 @@ namespace BSPF
return power2;
}
// Get next multiple of the given value
// Note that this only works when multiple is a power of two
inline size_t nextMultipleOf(size_t size, size_t multiple) {
return (size + multiple - 1) & ~(multiple - 1);
}
// Make 2D-arrays using std::array less verbose
template<typename T, size_t ROW, size_t COL>
using array2D = std::array<std::array<T, COL>, ROW>;

View File

@ -22,7 +22,7 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cartridge3E::Cartridge3E(const ByteBuffer& image, size_t size,
const string& md5, const Settings& settings)
: CartridgeEnhanced(image, size, BSPF::nextPowerOfTwo(size), md5, settings)
: CartridgeEnhanced(image, size, BSPF::nextMultipleOf(size, 1_KB), md5, settings)
{
myBankShift = BANK_SHIFT;
myRamSize = RAM_SIZE;