Skip to content

Commit 93c53f4

Browse files
committed
SNES: Added support for 4MB rom (#172)
1 parent 6fd3200 commit 93c53f4

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

retro-core/components/snes9x/src/memmap.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,7 @@ bool S9xInitMemory(void)
140140
Memory.RAM = (uint8_t*)malloc(RAM_SIZE);
141141
Memory.SRAM = (uint8_t*)malloc(SRAM_SIZE);
142142
Memory.VRAM = (uint8_t*)malloc(VRAM_SIZE);
143-
Memory.ROM = (uint8_t*)malloc(MAX_ROM_SIZE + 0x200);
144143
Memory.FillRAM = (uint8_t*)malloc(0x8000);
145-
Memory.ROM_AllocSize = MAX_ROM_SIZE + 0x200;
146144

147145
Memory.Map = (uint8_t**)calloc(MEMMAP_NUM_BLOCKS, sizeof(uint8_t*));
148146
Memory.MapInfo = (SMapInfo*)calloc(MEMMAP_NUM_BLOCKS, sizeof(SMapInfo));
@@ -154,6 +152,15 @@ bool S9xInitMemory(void)
154152

155153
bytes0x2000 = (uint8_t *)malloc(0x2000);
156154

155+
// Try to find the biggest (commercial) ROM size that can fit in our available memory.
156+
// const size_t AllocSizes[] = {0x800000, 0x600000, 0x400000, 0x300000, 0x280000, 0x200000, 0x100000, 0x80000, 0};
157+
const size_t AllocSizes[] = {0x400000, 0x200000, 0x80000, 0};
158+
for (const size_t *size = AllocSizes; *size && !Memory.ROM; ++size)
159+
{
160+
Memory.ROM_AllocSize = *size + 0x10000 + 0x200; // Extra 64KB for mapping purposes
161+
Memory.ROM = (uint8_t *)malloc(Memory.ROM_AllocSize);
162+
}
163+
157164
if (!Memory.RAM || !Memory.SRAM || !Memory.VRAM || !Memory.ROM || !Memory.Map || !Memory.MapInfo
158165
|| !IPPU.ScreenColors || !IPPU.TileCache || !IPPU.TileCached || !bytes0x2000)
159166
{

retro-core/components/snes9x/src/memmap.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ enum
8383

8484
enum
8585
{
86-
MAX_ROM_SIZE = 0x240000,
8786
RAM_SIZE = 0x20000,
8887
SRAM_SIZE = 0x10000, // 0x20000,
8988
VRAM_SIZE = 0x10000,

0 commit comments

Comments
 (0)