Merge remote-tracking branch 'TasVideos/master'

This commit is contained in:
mjbudd77 2021-09-17 22:36:30 -04:00
commit 0076f048f8
2 changed files with 40 additions and 13 deletions

View File

@ -102,6 +102,7 @@ static uint32 WRAMSIZE = 0;
static uint8 *WRAM = NULL;
static uint8 *MMC5fill = NULL;
static uint8 *ExRAM = NULL;
static uint8 MMC5battery = 0;
const int MMC5WRAMMAX = 1<<7; // 7 bits in register interface (real MMC5 has only 4 pins, however)
static uint8 MMC5WRAMsize; //configuration, not state
@ -924,9 +925,11 @@ static void GenMMC5Power(void) {
FCEU_dwmemset(MMC5fill + 0x000, nval | (nval<<8) | (nval<<16) | (nval<<24), 0x3C0);
FCEU_dwmemset(MMC5fill + 0x3C0, aval | (aval<<8) | (aval<<16) | (aval<<24), 0x040);
FCEU_MemoryRand(WRAM, MMC5WRAMsize * 8 * 1024);
FCEU_MemoryRand(MMC5fill,1024);
FCEU_MemoryRand(ExRAM,1024);
if(MMC5battery == 0) {
FCEU_MemoryRand(WRAM, MMC5WRAMsize * 8 * 1024);
FCEU_MemoryRand(MMC5fill,1024);
FCEU_MemoryRand(ExRAM,1024);
}
MMC5Synco();
@ -1000,6 +1003,9 @@ static void GenMMC5_Init(CartInfo *info, int wsize, int battery) {
MMC5fill = (uint8*)FCEU_malloc(1024);
ExRAM = (uint8*)FCEU_malloc(1024);
FCEU_MemoryRand(WRAM, MMC5WRAMsize * 8 * 1024);
FCEU_MemoryRand(MMC5fill,1024);
FCEU_MemoryRand(ExRAM,1024);
AddExState(ExRAM, 1024, 0, "ERAM");
AddExState(&MMC5HackSPMode, 1, 0, "SPLM");
@ -1013,6 +1019,7 @@ static void GenMMC5_Init(CartInfo *info, int wsize, int battery) {
GameStateRestore = MMC5_StateRestore;
info->Power = GenMMC5Power;
MMC5battery = battery;
if (battery) {
info->SaveGame[0] = WRAM;
if (info->ines2)

View File

@ -766,8 +766,18 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode) {
} else
Mirroring = (head.ROM_type & 1);
int not_round_size = head.ROM_size;
if(iNES2) not_round_size |= ((head.Upper_ROM_VROM_size & 0x0F) << 8);
int not_round_size;
if (!iNES2) {
not_round_size = head.ROM_size;
}
else {
if ((head.Upper_ROM_VROM_size & 0x0F) != 0x0F)
// simple notation
not_round_size = head.ROM_size | ((head.Upper_ROM_VROM_size & 0x0F) << 8);
else
// exponent-multiplier notation
not_round_size = ((1 << (head.ROM_size >> 2)) * ((head.ROM_size & 0b11) * 2 + 1)) >> 14;
}
if (!head.ROM_size && !iNES2)
ROM_size = 256;
@ -775,6 +785,16 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode) {
ROM_size = uppow2(not_round_size);
VROM_size = uppow2(head.VROM_size | (iNES2?((head.Upper_ROM_VROM_size & 0xF0)<<4):0));
if (!iNES2) {
VROM_size = head.VROM_size;
}
else {
if ((head.Upper_ROM_VROM_size & 0xF0) != 0xF0)
// simple notation
VROM_size = uppow2(head.VROM_size | ((head.Upper_ROM_VROM_size & 0xF0) << 4));
else
VROM_size = ((1 << (head.VROM_size >> 2)) * ((head.VROM_size & 0b11) * 2 + 1)) >> 13;
}
int round = true;
for (int i = 0; i != sizeof(not_power2) / sizeof(not_power2[0]); ++i) {
@ -832,9 +852,9 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode) {
iNESCart.CRC32 = iNESGameCRC32;
FCEU_printf(" PRG ROM: %3d x 16KiB\n", (round) ? ROM_size: not_round_size);
FCEU_printf(" CHR ROM: %3d x 8KiB\n", head.VROM_size);
FCEU_printf(" ROM CRC32: 0x%08lx\n", iNESGameCRC32);
FCEU_printf(" PRG ROM: %d x 16KiB = %d KiB\n", round ? ROM_size : not_round_size, (round ? ROM_size : not_round_size) * 16);
FCEU_printf(" CHR ROM: %d x 8KiB = %d KiB\n", VROM_size, VROM_size * 8);
FCEU_printf(" ROM CRC32: 0x%08lx\n", iNESGameCRC32);
{
int x;
FCEU_printf(" ROM MD5: 0x");
@ -852,7 +872,7 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode) {
}
}
FCEU_printf(" Mapper #: %d\n", MapperNo);
FCEU_printf(" Mapper #: %d\n", MapperNo);
FCEU_printf(" Mapper name: %s\n", mappername);
FCEU_printf(" Mirroring: %s\n", Mirroring == 2 ? "None (Four-screen)" : Mirroring ? "Vertical" : "Horizontal");
FCEU_printf(" Battery-backed: %s\n", (head.ROM_type & 2) ? "Yes" : "No");
@ -861,12 +881,12 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode) {
{
FCEU_printf(" NES2.0 Extensions\n");
FCEU_printf(" Sub Mapper #: %d\n", iNESCart.submapper);
FCEU_printf(" Total WRAM size: %d\n", iNESCart.wram_size + iNESCart.battery_wram_size);
FCEU_printf(" Total VRAM size: %d\n", iNESCart.vram_size + iNESCart.battery_vram_size);
FCEU_printf(" Total WRAM size: %d KiB\n", (iNESCart.wram_size + iNESCart.battery_wram_size) / 1024);
FCEU_printf(" Total VRAM size: %d KiB\n", (iNESCart.vram_size + iNESCart.battery_vram_size) / 1024);
if(head.ROM_type & 2)
{
FCEU_printf(" WRAM backed by battery: %d\n", iNESCart.battery_wram_size);
FCEU_printf(" VRAM backed by battery: %d\n", iNESCart.battery_vram_size);
FCEU_printf(" WRAM backed by battery: %d KiB\n", iNESCart.battery_wram_size / 1024);
FCEU_printf(" VRAM backed by battery: %d KiB\n", iNESCart.battery_vram_size / 1024);
}
}