Memory map all the available RAM

This commit is contained in:
Andre Leiradella
2017-07-13 00:23:01 +01:00
parent 863991a391
commit d854ca66f5
3 changed files with 29 additions and 2 deletions

View File

@@ -32,6 +32,7 @@
#include "fceu-memory.h"
static uint8 *CheatRPtrs[64];
uint8 *MMapPtrs[64];
void FCEU_CheatResetRAM(void) {
int x;
@@ -44,8 +45,10 @@ void FCEU_CheatAddRAM(int s, uint32 A, uint8 *p) {
uint32 AB = A >> 10;
int x;
for (x = s - 1; x >= 0; x--)
for (x = s - 1; x >= 0; x--) {
CheatRPtrs[AB + x] = p - A;
MMapPtrs[AB + x] = p + 1024 * x;
}
}

View File

@@ -1,6 +1,8 @@
#ifndef _FCEU_CHEAT_H
#define _FCEU_CHEAT_H
extern uint8 *MMapPtrs[64];
void FCEU_CheatResetRAM(void);
void FCEU_CheatAddRAM(int s, uint32 A, uint8 *p);

View File

@@ -1644,7 +1644,7 @@ extern uint32_t iNESGameCRC32;
bool retro_load_game(const struct retro_game_info *game)
{
unsigned i;
unsigned i, j;
char* dir=NULL;
char* sav_dir=NULL;
size_t fourscore_len = sizeof(fourscore_db_list) / sizeof(fourscore_db_list[0]);
@@ -1701,6 +1701,9 @@ bool retro_load_game(const struct retro_game_info *game)
{ 0 },
};
struct retro_memory_descriptor descs[64];
struct retro_memory_map mmaps;
if (!game)
return false;
@@ -1766,6 +1769,25 @@ bool retro_load_game(const struct retro_game_info *game)
}
}
memset(descs, 0, sizeof(descs));
i = 0;
for (j = 0; j < 64; j++)
{
if (MMapPtrs[j] != NULL)
{
descs[i].ptr = MMapPtrs[j];
descs[i].start = j * 1024;
descs[i].len = 1024;
descs[i].select = 0;
i++;
}
}
mmaps.descriptors = descs;
mmaps.num_descriptors = i;
environ_cb(RETRO_ENVIRONMENT_SET_MEMORY_MAPS, &mmaps);
return true;
}