saturnus: move cartridge allocations to special heaps

This commit is contained in:
nattthebear 2017-06-07 20:21:44 -04:00
parent 7d4b6a5209
commit 51d36f4563
9 changed files with 20 additions and 32 deletions

View File

@ -69,10 +69,10 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.Saturn
Path = comm.CoreFileProvider.DllPath(),
Filename = "ss.wbx",
SbrkHeapSizeKB = 32 * 1024,
SealedHeapSizeKB = 32 * 1024,
InvisibleHeapSizeKB = 32 * 1024,
MmapHeapSizeKB = 32 * 1024,
PlainHeapSizeKB = 32 * 1024,
SealedHeapSizeKB = 32 * 1024, // 512KB of bios
InvisibleHeapSizeKB = 32 * 1024, // 4MB of framebuffer
MmapHeapSizeKB = 32 * 1024, // not used?
PlainHeapSizeKB = 32 * 1024, // up to 16MB of cart ram
StartAddress = LibSaturnus.StartAddress
});
_core = BizInvoker.GetInvoker<LibSaturnus>(_exe, _exe);

View File

@ -12,18 +12,6 @@ using namespace MDFN_IEN_SS;
int32 (*FirmwareSizeCallback)(const char *filename);
void (*FirmwareDataCallback)(const char *filename, uint8 *dest);
std::unique_ptr<MemoryStream> GetFirmware(const char *filename)
{
int32 length = FirmwareSizeCallback(filename);
auto buffer = new uint8[length];
FirmwareDataCallback(filename, buffer);
auto ms = std::unique_ptr<MemoryStream>(new MemoryStream(length, true));
ms->write(buffer, length);
ms->seek(0, SEEK_SET);
delete[] buffer;
return ms;
}
EXPORT void SetFirmwareCallbacks(int32 (*sizecallback)(const char *filename), void (*datacallback)(const char *filename, uint8 *dest))
{
FirmwareSizeCallback = sizecallback;

View File

@ -144,9 +144,7 @@ void CART_Init(const int cart_type)
case CART_KOF95:
case CART_ULTRAMAN:
{
auto fp = GetFirmware(cart_type == CART_KOF95 ? "ss.cart.kof95_path" : "ss.cart.ultraman_path");
CART_ROM_Init(&Cart, fp.get());
CART_ROM_Init(&Cart, cart_type == CART_KOF95 ? "ss.cart.kof95_path" : "ss.cart.ultraman_path");
}
break;

View File

@ -25,7 +25,7 @@
namespace MDFN_IEN_SS
{
static uint8 ExtBackupRAM[0x80000];
static uint8* ExtBackupRAM;
static bool ExtBackupRAM_Dirty;
// TODO: Check mirroring.
@ -64,14 +64,15 @@ static MDFN_COLD void GetNVInfo(const char** ext, void** nv_ptr, uint64* nv_size
{
*ext = "bcr";
*nv_ptr = ExtBackupRAM;
*nv_size = sizeof(ExtBackupRAM);
*nv_size = 524288;
}
void CART_Backup_Init(CartInfo* c)
{
static const uint8 init[0x10] = { 0x42, 0x61, 0x63, 0x6B, 0x55, 0x70, 0x52, 0x61, 0x6D, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x61, 0x74 };
memset(ExtBackupRAM, 0x00, sizeof(ExtBackupRAM));
ExtBackupRAM = (uint8*)alloc_plain(524288);
memset(ExtBackupRAM, 0x00, 524288);
for(unsigned i = 0; i < 0x200; i += 0x10)
memcpy(ExtBackupRAM + i, init, 0x10);

View File

@ -46,7 +46,7 @@ static MDFN_COLD void Reset(bool powering_up)
void CART_CS1RAM_Init(CartInfo* c)
{
CS1RAM = new uint16[0x1000000 / sizeof(uint16)];
CS1RAM = (uint16*)alloc_plain(0x1000000);
SS_SetPhysMemMap (0x04000000, 0x04FFFFFF, CS1RAM, 0x1000000, true);
c->CS01_SetRW8W16(0x04000000, 0x04FFFFFF,

View File

@ -24,7 +24,7 @@
namespace MDFN_IEN_SS
{
static uint16 ExtRAM[0x200000];
static uint16* ExtRAM; //[0x200000];
static size_t ExtRAM_Mask;
static uint8 Cart_ID;
@ -51,11 +51,12 @@ static MDFN_HOT void CartID_Read_DB(uint32 A, uint16* DB)
static MDFN_COLD void Reset(bool powering_up)
{
if(powering_up)
memset(ExtRAM, 0, sizeof(ExtRAM)); // TODO: Test.
memset(ExtRAM, 0, 0x400000); // TODO: Test.
}
void CART_ExtRAM_Init(CartInfo* c, bool R4MiB)
{
ExtRAM = (uint16*)alloc_plain(0x400000);
if(R4MiB)
{
Cart_ID = 0x5C;

View File

@ -25,7 +25,7 @@
namespace MDFN_IEN_SS
{
static uint16 ROM[0x100000];
static uint16* ROM; //[0x100000];
static MDFN_HOT void ROM_Read(uint32 A, uint16* DB)
{
@ -34,9 +34,12 @@ static MDFN_HOT void ROM_Read(uint32 A, uint16* DB)
*DB = *(uint16*)((uint8*)ROM + (A & 0x1FFFFE));
}
void CART_ROM_Init(CartInfo* c, Stream* str)
void CART_ROM_Init(CartInfo* c, const char* filename)
{
str->read(ROM, 0x200000);
if (FirmwareSizeCallback(filename) != 0x200000)
abort();
ROM = (uint16*)alloc_sealed(0x200000);
FirmwareDataCallback(filename, (uint8*)ROM);
for(unsigned i = 0; i < 0x100000; i++)
{

View File

@ -24,7 +24,7 @@
namespace MDFN_IEN_SS
{
void CART_ROM_Init(CartInfo* c, Stream* str) MDFN_COLD;
void CART_ROM_Init(CartInfo* c, const char* filename) MDFN_COLD;
}
#endif

View File

@ -302,9 +302,6 @@ inline char *strdup(const char *p)
#include <emulibc.h>
// returns a firmware file suitable for use by the core
std::unique_ptr<MemoryStream> GetFirmware(const char *filename);
extern int32 (*FirmwareSizeCallback)(const char *filename);
extern void (*FirmwareDataCallback)(const char *filename, uint8 *dest);