Merge pull request #343 from negativeExponent/updates_and_fixes

misc updates
This commit is contained in:
hizzlekizzle
2020-03-17 10:23:00 -05:00
committed by GitHub
22 changed files with 53 additions and 36 deletions

View File

@@ -75,6 +75,7 @@ static void M199Power(void) {
}
static void M199Close(void) {
GenMMC3Close();
if (CHRRAM)
FCEU_gfree(CHRRAM);
CHRRAM = NULL;

View File

@@ -21,7 +21,7 @@
#include "mapinc.h"
#include "mmc3.h"
static uint8 lut[256] = {
static const uint8 lut[256] = {
0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x49, 0x19, 0x09, 0x59, 0x49, 0x19, 0x09,
0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x51, 0x41, 0x11, 0x01, 0x51, 0x41, 0x11, 0x01,
0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x49, 0x19, 0x09, 0x59, 0x49, 0x19, 0x09,

View File

@@ -53,7 +53,7 @@ static void Sync(void) {
}
static DECLFW(M225Write) {
uint32 bank = (A >> 14) & 1;
uint8 bank = (A >> 14) & 1;
mirr = (A >> 13) & 1;
mode = (A >> 12) & 1;
chr = (A & 0x3f) | (bank << 6);

View File

@@ -31,7 +31,7 @@ static uint8 *CHRROM;
static uint32 CHRROMSIZE;
static void M269CW(uint32 A, uint8 V) {
uint32 NV = V;
uint16 NV = V;
if (EXPREGS[2] & 8)
NV &= (1 << ((EXPREGS[2] & 7) + 1)) - 1;
NV |= EXPREGS[0] | ((EXPREGS[2] & 0xF0) << 4);
@@ -39,7 +39,7 @@ static void M269CW(uint32 A, uint8 V) {
}
static void M269PW(uint32 A, uint8 V) {
uint32 MV = V & ((EXPREGS[3] & 0x3F) ^ 0x3F);
uint16 MV = V & ((EXPREGS[3] & 0x3F) ^ 0x3F);
MV |= EXPREGS[1];
MV |= ((EXPREGS[3] & 0x40) << 2);
setprg8(A, MV);
@@ -55,6 +55,7 @@ static DECLFW(M269Write5) {
}
static void M269Close(void) {
GenMMC3Close();
if (CHRROM)
FCEU_free(CHRROM);
CHRROM = NULL;
@@ -67,25 +68,19 @@ static void M269Reset(void) {
}
static void M269Power(void) {
uint32 i;
EXPREGS[0] = EXPREGS[1] = EXPREGS[3] = EXPREGS[4] = 0;
EXPREGS[2] = 0x0F;
GenMMC3Power();
SetWriteHandler(0x5000, 0x5FFF, M269Write5);
}
CHRROMSIZE = PRGsize[0];
CHRROM = (uint8*)FCEU_gmalloc(CHRROMSIZE);
/* Decrypt CHR data */
for (i = 0; i < CHRROMSIZE; i++) {
uint8_t Val = PRGptr[0][i];
Val = ((Val & 1) << 6) | ((Val & 2) << 3) | ((Val & 4) << 0) | ((Val & 8) >> 3) | ((Val & 16) >> 3) | ((Val & 32) >> 2) | ((Val & 64) >> 1) | ((Val & 128) << 0);
CHRROM[i] = Val;
}
SetupCartCHRMapping(0, CHRROM, CHRROMSIZE, 0);
AddExState(CHRROM, CHRROMSIZE, 0, "_CHR");
static uint8 unscrambleCHR(uint8 data) {
return ((data & 0x01) << 6) | ((data & 0x02) << 3) | ((data & 0x04) << 0) | ((data & 0x08) >> 3) |
((data & 0x10) >> 3) | ((data & 0x20) >> 2) | ((data & 0x40) >> 1) | ((data & 0x80) << 0);
}
void Mapper269_Init(CartInfo *info) {
int i;
GenMMC3_Init(info, 512, 0, 8, 0);
cwrap = M269CW;
pwrap = M269PW;
@@ -93,4 +88,12 @@ void Mapper269_Init(CartInfo *info) {
info->Reset = M269Reset;
info->Close = M269Close;
AddExState(EXPREGS, 5, 0, "EXPR");
CHRROMSIZE = PRGsize[0];
CHRROM = (uint8*)FCEU_gmalloc(CHRROMSIZE);
/* unscramble CHR data from PRG */
for (i = 0; i < CHRROMSIZE; i++)
CHRROM[i] = unscrambleCHR(PRGptr[0][i]);
SetupCartCHRMapping(0, CHRROM, CHRROMSIZE, 0);
AddExState(CHRROM, CHRROMSIZE, 0, "_CHR");
}

View File

@@ -41,7 +41,7 @@ static void M353PPU(uint32 A) {
}
static void M353PW(uint32 A, uint8 V) {
uint32 bank = V;
uint8 bank = V;
if (EXPREGS[0] == 2) {
bank &= 0x0F;
@@ -110,6 +110,7 @@ static void M353Reset(void) {
}
static void M353Close(void) {
GenMMC3Close();
if (CHRRAM)
FCEU_gfree(CHRRAM);
CHRRAM = NULL;

View File

@@ -30,7 +30,7 @@ static uint32 CHRRAMSIZE = 0;
static void M356CW(uint32 A, uint8 V) {
if (EXPREGS[2] & 0x20) {
uint32 NV = V;
uint8 NV = V;
if (EXPREGS[2] & 8)
NV &= (1 << ((EXPREGS[2] & 7) + 1)) - 1;
else
@@ -43,7 +43,7 @@ static void M356CW(uint32 A, uint8 V) {
}
static void M356PW(uint32 A, uint8 V) {
uint32 MV = V & ((EXPREGS[3] & 0x3F) ^ 0x3F);
uint8 MV = V & ((EXPREGS[3] & 0x3F) ^ 0x3F);
MV |= EXPREGS[1];
if (UNIFchrrama)
MV |= ((EXPREGS[2] & 0x40) << 2);
@@ -67,6 +67,7 @@ static DECLFW(M356Write) {
}
static void M356Close(void) {
GenMMC3Close();
if (CHRRAM)
FCEU_free(CHRRAM);
CHRRAM = NULL;

View File

@@ -31,8 +31,8 @@ static uint8 preg[4];
static uint8 dipswitch;
static uint32 IRQCount, IRQa;
static uint8 banks[8] = { 4, 3, 5, 3, 6, 3, 7, 3 };
static uint8 outer_bank[4] = { 0x00, 0x08, 0x10, 0x18 };
static const uint8 banks[8] = { 4, 3, 5, 3, 6, 3, 7, 3 };
static const uint8 outer_bank[4] = { 0x00, 0x08, 0x10, 0x18 };
static SFORMAT StateRegs[] =
{

View File

@@ -52,8 +52,8 @@ static SFORMAT StateRegs[] = {
};
static void Sync(void) {
uint32 prgMask = 0x3F;
uint32 prgOuterBank = (exRegs[0] & 0x38) << 1;
uint8 prgMask = 0x3F;
uint8 prgOuterBank = (exRegs[0] & 0x38) << 1;
switch (exRegs[1] & 3) {
case 0: prgMask = 0x3F; break;
@@ -71,9 +71,10 @@ static void Sync(void) {
if (!UNIFchrrama) {
switch (mapperNum) {
case 359: {
uint32 chrMask = (exRegs[1] & 0x40) ? 0xFF : 0x7F;
uint32 chrOuterBank = (exRegs[3] << 7);
uint32 i;
uint8 i;
uint8 chrMask = (exRegs[1] & 0x40) ? 0xFF : 0x7F;
uint16 chrOuterBank = (exRegs[3] << 7);
for (i = 0; i < 8; i++)
setchr1(i << 10, (creg[i] & chrMask) | chrOuterBank);
} break;
@@ -123,19 +124,19 @@ static DECLFW(M359WriteIRQ) {
}
static DECLFW(M359WritePRG) {
uint32 i = A & 3;
uint8 i = A & 3;
preg[i] = V;
Sync();
}
static DECLFW(M359WriteCHR) {
uint32 i = ((A >> 10) & 4) | (A & 3);
uint8 i = ((A >> 10) & 4) | (A & 3);
creg[i] = V;
Sync();
}
static DECLFW(M359WriteEx) {
uint32 i = A & 3;
uint8 i = A & 3;
exRegs[i] = V;
Sync();
}

View File

@@ -29,9 +29,6 @@ static uint8 smb2_reg;
static uint8 smb2j_enabled;
static uint16 smb2j_count;
static uint32 WRAMSIZE;
static uint8 *WRAM;
static SFORMAT StateRegs[] = {
{ &mode, 1, "MODE" },
{ &mmc3_reload, 1, "IRQR" },

View File

@@ -90,6 +90,7 @@ static void M372Power(void) {
}
static void M372Close(void) {
GenMMC3Close();
if (CHRRAM)
FCEU_gfree(CHRRAM);
CHRRAM = NULL;

View File

@@ -26,7 +26,7 @@
#include "mapinc.h"
#include "mmc3.h"
static uint8 lut[4] = { 0x00, 0x02, 0x02, 0x03 };
static const uint8 lut[4] = { 0x00, 0x02, 0x02, 0x03 };
static DECLFW(UNL6035052ProtWrite) {
EXPREGS[0] = lut[V & 3];

View File

@@ -175,6 +175,10 @@ static void BS110Reset(void)
MMC3RegReset();
}
static void BS110Close(void) {
GenMMC3Close();
if (WRAM)
FCEU_free(WRAM);
WRAM = NULL;
}
void BS110_Init(CartInfo *info) {

View File

@@ -213,6 +213,7 @@ static void Bs5652Reset(void)
static void Bs5652Close(void)
{
GenMMC3Close();
if (WRAM)
FCEU_gfree(WRAM);
WRAM = NULL;

View File

@@ -162,6 +162,7 @@ static void NC7000MReset(void) {
MMC3RegReset();
}
static void NC7000MClose(void) {
GenMMC3Close();
if (WRAM)
FCEU_gfree(WRAM);
WRAM = NULL;

View File

@@ -83,6 +83,7 @@ static void BMC1024CA1Power(void) {
}
static void BMC1024CA1Close(void) {
GenMMC3Close();
if (CHRRAM)
FCEU_gfree(CHRRAM);
CHRRAM = NULL;

View File

@@ -90,6 +90,7 @@ static void BMC810131C_Power(void) {
}
static void BMC810131C_Close(void) {
GenMMC3Close();
if (CHRRAM)
FCEU_gfree(CHRRAM);
CHRRAM = NULL;

View File

@@ -289,7 +289,7 @@ void GenMMC3Power(void) {
FCEU_dwmemset(CHRRAM, 0, CHRRAMSIZE);
}
static void GenMMC3Close(void) {
void GenMMC3Close(void) {
if (CHRRAM)
FCEU_gfree(CHRRAM);
if (WRAM)

View File

@@ -21,6 +21,7 @@ extern void (*mwrap)(uint8 V);
void GenMMC3Power(void);
void GenMMC3Restore(int version);
void MMC3RegReset(void);
void GenMMC3Close(void);
void FixMMC3PRG(int V);
void FixMMC3CHR(int V);
DECLFW(MMC3_CMDWrite);

View File

@@ -61,6 +61,7 @@ static void MSHPower(void) {
}
static void MSHClose(void) {
GenMMC3Close();
if (CHRRAM)
FCEU_gfree(CHRRAM);
CHRRAM = NULL;

View File

@@ -76,6 +76,7 @@ static void Super24Reset(void) {
}
static void Super24Close(void) {
GenMMC3Close();
if (CHRRAM)
FCEU_gfree(CHRRAM);
CHRRAM = NULL;

View File

@@ -65,7 +65,8 @@ typedef struct {
static TXC txc;
static void (*WSync)(void);
static void Dummyfunc(void) { };
static void (*WSync)(void) = Dummyfunc;
static SFORMAT StateRegs[] =
{

View File

@@ -806,8 +806,8 @@ int UNIFLoad(const char *name, FCEUFILE *fp) {
if (UNIFCart.mapper)
FCEU_printf(" [Unif] Mapper: %d\n", UNIFCart.mapper);
FCEU_printf(" [Unif] SubMapper: %d\n", UNIFCart.submapper);
FCEU_printf(" [Unif] PRG ROM: %u KiB\n", UNIF_PRGROMSize / 1024);
FCEU_printf(" [Unif] CHR ROM: %u KiB\n", UNIF_CHRROMSize / 1024);
FCEU_printf(" [Unif] PRG ROM: %u KiB\n", UNIFCart.PRGRomSize / 1024);
FCEU_printf(" [Unif] CHR ROM: %u KiB\n", UNIFCart.CHRRomSize / 1024);
GameInterface = UNIFGI;