Merge pull request #19 from TASVideos/master

Sync code to the newest
This commit is contained in:
owomomo 2020-05-11 22:04:54 +08:00 committed by GitHub
commit b20093f572
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 77 additions and 6 deletions

View File

@ -1363,3 +1363,30 @@ void TQROM_Init(CartInfo *info) {
void HKROM_Init(CartInfo *info) {
GenMMC3_Init(info, 512, 512, 1, info->battery);
}
// -------------------------------- iNES 2.0 ----------------------------
// ---------------------------- Mapper 406 ------------------------------
static DECLFW(M406CMDWrite) {
MMC3_CMDWrite((A & 0xFFFE) | ((A & 2) >> 1), V);
}
static DECLFW(M406IRQWrite) {
MMC3_IRQWrite((A & 0xFFFE) | ((A & 2) >> 1), V);
}
static DECLFW(M406Write) {
}
static void M406_Power(void) {
GenMMC3Power();
// TODO : FLASH
SetWriteHandler(0x8000, 0xBFFF, M406CMDWrite);
SetWriteHandler(0xC000, 0xFFFF, M406IRQWrite);
}
void Mapper406_Init(CartInfo *info) {
GenMMC3_Init(info, 512, 256, 0, 0);
info->Power = M406_Power;
}

View File

@ -157,7 +157,10 @@ static void FixCache(int a, int V) {
case 0x02: FreqCache[w] &= ~0x0000FF00; FreqCache[w] |= V << 8; break;
case 0x04:
FreqCache[w] &= ~0x00030000; FreqCache[w] |= (V & 3) << 16;
LengthCache[w] = (8 - ((V >> 2) & 7)) << 2;
// something wrong here http://www.romhacking.net/forum/index.php?topic=21907.msg306903#msg306903
// LengthCache[w] = (8 - ((V >> 2) & 7)) << 2;
// fix be like in https://github.com/SourMesen/Mesen/blob/cda0a0bdcb5525480784f4b8c71de6fc7273b570/Core/Namco163Audio.h#L61
LengthCache[w] = 256 - (V & 0xFC);
break;
case 0x07: EnvCache[w] = (double)(V & 0xF) * 576716; break;
}

View File

@ -132,6 +132,11 @@ void SetupCartCHRMapping(int chip, uint8 *p, uint32 size, int ram) {
CHRmask4[chip] = (size >> 12) - 1;
CHRmask8[chip] = (size >> 13) - 1;
if (CHRmask1[chip] >= (unsigned int)(-1)) CHRmask1[chip] = 0;
if (CHRmask2[chip] >= (unsigned int)(-1)) CHRmask2[chip] = 0;
if (CHRmask4[chip] >= (unsigned int)(-1)) CHRmask4[chip] = 0;
if (CHRmask8[chip] >= (unsigned int)(-1)) CHRmask8[chip] = 0;
CHRram[chip] = ram;
}

View File

@ -281,4 +281,6 @@
{0x4d4a0e1b, 260|0x1000,-1},
{0xb6dd2c9d, 260|0x1000,-1},
{0xb02fcb57, 406|0x1000,-1}, /* Haradius Zero ver 1.2a 2019 */
{0x00000000, -1, -1}

View File

@ -725,6 +725,9 @@ BMAPPINGLocal bmap[] = {
{"F-15 MMC3 Based", 259, BMCF15_Init},
{"HP10xx/H20xx Boards", 260, BMCHPxx_Init},
{"810544-CA-1", 261, BMC810544CA1_Init},
{"Impact Soft MMC3 Flash Board", 406, Mapper406_Init },
{"KONAMI QTAi Board", 547, QTAi_Init },
{"", 0, NULL}
@ -892,8 +895,31 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode) {
iNESCart.battery = (head.ROM_type & 2) ? 1 : 0;
iNESCart.mirror = Mirroring;
if (!iNES_Init(MapperNo))
int result = iNES_Init(MapperNo);
switch(result)
{
case 0:
goto init_ok;
case 1:
FCEU_PrintError("iNES mapper #%d is not supported at all.", MapperNo);
goto init_ok; // this error is still allowed to run as NROM?
case 2:
FCEU_PrintError("Unable to allocate CHR-RAM.");
break;
case 3:
FCEU_PrintError("CHR-RAM size < 1k is not supported.");
break;
}
if (ROM) free(ROM);
if (VROM) free(VROM);
if (trainerpoo) free(trainerpoo);
if (ExtraNTARAM) free(ExtraNTARAM);
ROM = NULL;
VROM = NULL;
trainerpoo = NULL;
ExtraNTARAM = NULL;
return 0;
init_ok:
GameInfo->mappernum = MapperNo;
FCEU_LoadGameSave(&iNESCart);
@ -1017,7 +1043,8 @@ static int iNES_Init(int num) {
{
CHRRAMSize = iNESCart.battery_vram_size + iNESCart.vram_size;
}
if ((VROM = (uint8*)FCEU_dmalloc(CHRRAMSize)) == NULL) return 0;
if (CHRRAMSize < 1024) return 3; // unsupported size, VPage only goes down to 1k banks, NES program can corrupt memory if used
if ((VROM = (uint8*)FCEU_dmalloc(CHRRAMSize)) == NULL) return 2;
FCEU_MemoryRand(VROM, CHRRAMSize);
UNIFchrrama = VROM;
@ -1037,9 +1064,9 @@ static int iNES_Init(int num) {
if (head.ROM_type & 8)
AddExState(ExtraNTARAM, 2048, 0, "EXNR");
tmp->init(&iNESCart);
return 1;
return 0;
}
tmp++;
}
return 0;
return 1;
}

View File

@ -267,6 +267,7 @@ void Mapper250_Init(CartInfo *);
void Mapper252_Init(CartInfo *);
void Mapper253_Init(CartInfo *);
void Mapper254_Init(CartInfo *);
void Mapper406_Init(CartInfo *);
typedef struct {
char *name;

View File

@ -1669,7 +1669,12 @@ static void CopySprites(uint8 *target) {
if (!rendersprites) return; //User asked to not display sprites.
if(!SpriteON) return;
for(int i=0;i<256;i++)
int start=8;
if(PPU[1] & 0x04)
start = 0;
for(int i=start;i<256;i++)
{
uint8 t = sprlinebuf[i];
if(!(t&0x80))

View File

@ -181,6 +181,7 @@ void LogDPCM(int romaddress, int dpcmsize){
for (int dpcmstart = i; dpcmstart < (i + dpcmsize); dpcmstart++) {
if(!(cdloggerdata[dpcmstart] & 0x40)) {
cdloggerdata[dpcmstart] |= 0x40;
cdloggerdata[dpcmstart] |= (romaddress >> 11) & 0x0c;
if(!(cdloggerdata[dpcmstart] & 2)){
datacount++;