mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
core, always allocate a power of 2 for cartridges
This commit is contained in:
parent
12d506baa8
commit
28165a19e4
1 changed files with 9 additions and 8 deletions
17
pico/cart.c
17
pico/cart.c
|
@ -713,21 +713,22 @@ static unsigned char *PicoCartAlloc(int filesize, int is_sms)
|
||||||
{
|
{
|
||||||
unsigned char *rom;
|
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) {
|
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
|
// be sure we can cover all address space
|
||||||
if (rom_alloc_size < 0x10000)
|
if (rom_alloc_size < 0x10000)
|
||||||
rom_alloc_size = 0x10000;
|
rom_alloc_size = 0x10000;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// align to 512K for memhandlers
|
// 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)
|
if (rom_alloc_size - filesize < 4)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue