Skip to content

Commit

Permalink
SNES: Added support for 4MB rom (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
ducalex committed Dec 24, 2024
1 parent 6fd3200 commit 48a164a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 9 additions & 2 deletions retro-core/components/snes9x/src/memmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,7 @@ bool S9xInitMemory(void)
Memory.RAM = (uint8_t*)malloc(RAM_SIZE);
Memory.SRAM = (uint8_t*)malloc(SRAM_SIZE);
Memory.VRAM = (uint8_t*)malloc(VRAM_SIZE);
Memory.ROM = (uint8_t*)malloc(MAX_ROM_SIZE + 0x200);
Memory.FillRAM = (uint8_t*)malloc(0x8000);
Memory.ROM_AllocSize = MAX_ROM_SIZE + 0x200;

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

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

// Try to find the biggest (commercial) ROM size that can fit in our available memory.
// const size_t AllocSizes[] = {0x600000, 0x400000, 0x300000, 0x280000, 0x200000, 0x100000, 0x80000, 0};
const size_t AllocSizes[] = {0x400000, 0x200000, 0x80000, 0};
for (const size_t *size = AllocSizes; *size && !Memory.ROM; ++size)
{
Memory.ROM_AllocSize = *size + 0x10000 + 0x200; // Extra 64KB for mapping purposes
Memory.ROM = (uint8_t *)malloc(Memory.ROM_AllocSize);
}

if (!Memory.RAM || !Memory.SRAM || !Memory.VRAM || !Memory.ROM || !Memory.Map || !Memory.MapInfo
|| !IPPU.ScreenColors || !IPPU.TileCache || !IPPU.TileCached || !bytes0x2000)
{
Expand Down
1 change: 0 additions & 1 deletion retro-core/components/snes9x/src/memmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ enum

enum
{
MAX_ROM_SIZE = 0x240000,
RAM_SIZE = 0x20000,
SRAM_SIZE = 0x10000, // 0x20000,
VRAM_SIZE = 0x10000,
Expand Down

0 comments on commit 48a164a

Please sign in to comment.