core, always allocate a power of 2 for cartridges

This commit is contained in:
kub 2023-06-05 18:04:24 +00:00
parent 12d506baa8
commit 28165a19e4

View file

@ -713,21 +713,22 @@ static unsigned char *PicoCartAlloc(int filesize, int is_sms)
{
unsigned char *rom;
// make size power of 2 for easier banking handling
int s = 0, tmp = filesize;
while ((tmp >>= 1) != 0)
s++;
if (filesize > (1 << s))
s++;
rom_alloc_size = 1 << s;
if (is_sms) {
// make size power of 2 for easier banking handling
int s = 0, tmp = filesize;
while ((tmp >>= 1) != 0)
s++;
if (filesize > (1 << s))
s++;
rom_alloc_size = 1 << s;
// be sure we can cover all address space
if (rom_alloc_size < 0x10000)
rom_alloc_size = 0x10000;
}
else {
// align to 512K for memhandlers
rom_alloc_size = (filesize + 0x7ffff) & ~0x7ffff;
rom_alloc_size = (rom_alloc_size + 0x7ffff) & ~0x7ffff;
}
if (rom_alloc_size - filesize < 4)