mapper 43 - new dumps needed

UNIF mihunche - new source for the old board/mapper
UNIF PEC-586 - new mapper almost complete
This commit is contained in:
CaH4e3 2013-05-13 19:27:34 +00:00
parent dad4e753f6
commit d5e6d7f891
13 changed files with 275 additions and 157 deletions

View File

@ -16,13 +16,14 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* FDS Conversion
*
*/
//ccording to nestopia, BTL_SMB2_C, otherwise known as UNL-SMB2J
#include "mapinc.h"
static uint8 reg;
static uint8 reg, swap;
static uint32 IRQCount, IRQa;
static SFORMAT StateRegs[] =
@ -30,16 +31,17 @@ static SFORMAT StateRegs[] =
{ &IRQCount, 4, "IRQC" },
{ &IRQa, 4, "IRQA" },
{ &reg, 1, "REG" },
{ &swap, 1, "SWAP" },
{ 0 }
};
static void Sync(void) {
setprg4(0x5000, 16); // Only YS-612 advdnced version
setprg8(0x6000, 2);
setprg4(0x5000, 16); // Only YS-612 advanced version
setprg8(0x6000, swap?0:2);
setprg8(0x8000, 1);
setprg8(0xa000, 0);
setprg8(0xc000, reg);
setprg8(0xe000, 9);
setprg8(0xe000, swap?8:9);
setchr8(0);
}
@ -48,13 +50,14 @@ static DECLFW(M43Write) {
int transo[8] = { 4, 3, 5, 3, 6, 3, 7, 3 }; // According to hardware tests
switch (A & 0xf1ff) {
case 0x4022: reg = transo[V & 7]; Sync(); break;
case 0x4120: swap = V & 1; Sync(); break;
case 0x8122: // hacked version
case 0x4122: IRQa = V & 1; X6502_IRQEnd(FCEU_IQEXT); IRQCount = 0; break; // original version
}
}
static void M43Power(void) {
reg = 0;
reg = swap = 0;
Sync();
SetReadHandler(0x5000, 0xffff, CartBR);
SetWriteHandler(0x4020, 0xffff, M43Write);

View File

@ -85,18 +85,6 @@ static void Latch_Init(CartInfo *info, void (*proc)(void), readfunc func, uint16
AddExState(&latche, 2, 0, "LATC");
}
//------------------ UNLCC21 ---------------------------
static void UNLCC21Sync(void) {
setprg32(0x8000, 0);
setchr8(latche & 1);
setmirror(MI_0 + ((latche & 2) >> 1));
}
void UNLCC21_Init(CartInfo *info) {
Latch_Init(info, UNLCC21Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0);
}
//------------------ BMCD1038 ---------------------------
static void BMCD1038Sync(void) {

View File

@ -159,7 +159,7 @@ static void ANROMSync() {
}
void ANROM_Init(CartInfo *info) {
Latch_Init(info, ANROMSync, 0, 0x8000, 0xFFFF, 0, 0);
Latch_Init(info, ANROMSync, 0, 0x4020, 0xFFFF, 0, 0);
}
//------------------ Map 8 ---------------------------
@ -215,7 +215,6 @@ void Mapper38_Init(CartInfo *info) {
//------------------ Map 66 ---------------------------
static void MHROMSync(void) {
setprg32(0x8000, latche >> 4);
setchr8(latche & 0xF);
}

View File

@ -0,0 +1,68 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2013 CaH4e3
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "mapinc.h"
static uint16 latche;
static SFORMAT StateRegs[] =
{
{ &latche, 2, "LATC" },
{ 0 }
};
static void Sync(void) {
setprg32(0x8000, 0);
if(CHRsize[0] == 8192) {
setchr4(0x0000, latche & 1);
setchr4(0x1000, latche & 1);
} else {
setchr8(latche & 1); // actually, my bad, overdumped roms, the real CHR size if 8K
}
setmirror(MI_0 + (latche & 1));
}
static DECLFW(UNLCC21Write1) {
latche = A;
Sync();
}
static DECLFW(UNLCC21Write2) {
latche = V;
Sync();
}
static void UNLCC21Power(void) {
latche = 0;
Sync();
SetReadHandler(0x8000, 0xFFFF, CartBR);
SetWriteHandler(0x8001, 0xFFFF, UNLCC21Write1);
SetWriteHandler(0x8000, 0x8000, UNLCC21Write2); // another one many-in-1 mapper, there is a lot of similar carts with little different wirings
}
static void StateRestore(int version) {
Sync();
}
void UNLCC21_Init(CartInfo *info) {
info->Power = UNLCC21Power;
GameStateRestore = StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -20,13 +20,15 @@
#include "mapinc.h"
static uint8 reg[7];
static uint8 reg[7], debug = 1;
static uint32 lastnt = 0;
static uint8 *WRAM = NULL;
static uint32 WRAMSIZE;
static SFORMAT StateRegs[] =
{
{ reg, 2, "REG" },
{ &lastnt, 4, "LNT" },
{ 0 }
};
@ -46,9 +48,13 @@ static uint8 br_tbl[16] = {
};
static void Sync(void) {
// setchr4(0x0000,(reg[0]&0x80) >> 7);
// setchr4(0x1000,(reg[0]&0x80) >> 7);
setchr8(0);
if (reg[0]&0x80) {
setchr4(0x0000, (lastnt >> 9) ^ 0);
setchr4(0x1000, (lastnt >> 9) ^ 1);
} else {
setchr4(0x0000, 1);
setchr4(0x1000, 0);
}
setprg8r(0x10, 0x6000, 0);
setprg16(0x8000, bs_tbl[reg[0] & 0x7f] >> 4);
setprg16(0xc000, bs_tbl[reg[0] & 0x7f] & 0xf);
@ -57,17 +63,18 @@ static void Sync(void) {
static DECLFW(UNLPEC586Write) {
reg[(A & 0x700) >> 8] = V;
FCEU_printf("bs %04x %02x\n", A, V);
// FCEU_printf("bs %04x %02x\n", A, V);
Sync();
}
static DECLFR(UNLPEC586Read) {
FCEU_printf("read %04x\n", A);
// FCEU_printf("read %04x\n", A);
return (X.DB & 0xD8) | br_tbl[reg[4] >> 4];
}
static void UNLPEC586Power(void) {
reg[0] = 0x0E;
debug ^= 1;
Sync();
setchr8(0);
SetReadHandler(0x6000, 0x7FFF, CartBR);
@ -77,16 +84,21 @@ static void UNLPEC586Power(void) {
SetReadHandler(0x5000, 0x5fff, UNLPEC586Read);
}
static void UNLPEC586IRQ(void) {
// if(reg[0]&0x80)
static void UNLPEC586PPU(uint32 A) {
if (reg[0]&0x80)
{
if (scanline == 128) {
if (((A & 0x3FFF) > 0x2000) && ((A & 0x3FFF) < 0x23C0)) {
uint32 curnt = A & 0x200;
if (curnt != lastnt) {
setchr4(0x0000, (curnt >> 9) ^ 0);
setchr4(0x1000, (curnt >> 9) ^ 1);
lastnt = curnt;
}
}
} else {
lastnt = 0;
setchr4(0x0000, 1);
setchr4(0x1000, 0);
} else {
setchr4(0x0000, 0);
setchr4(0x1000, 1);
}
}
}
@ -103,9 +115,11 @@ static void StateRestore(int version) {
void UNLPEC586Init(CartInfo *info) {
info->Power = UNLPEC586Power;
info->Close = UNLPEC586Close;
GameHBIRQHook = UNLPEC586IRQ;
PPU_hook = UNLPEC586PPU;
GameStateRestore = StateRestore;
PEC586Hack = 1;
WRAMSIZE = 8192;
WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE);
SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1);

View File

@ -378,6 +378,7 @@ void ResetGameLoaded(void) {
memset(&GameExpSound, 0, sizeof(GameExpSound));
MapIRQHook = NULL;
MMC5Hack = 0;
PEC586Hack = 0;
PAL &= 1;
pale = 0;
}

View File

@ -39,7 +39,7 @@ char *FCEUI_GetAboutString();
extern uint64 timestampbase;
extern uint32 MMC5HackVROMMask;
extern uint8 *MMC5HackExNTARAMPtr;
extern int MMC5Hack;
extern int MMC5Hack, PEC586Hack;
extern uint8 *MMC5HackVROMPTR;
extern uint8 MMC5HackCHRMode;
extern uint8 MMC5HackSPMode;

View File

@ -311,7 +311,7 @@ int fceuindbg = 0;
//0xFF shall indicate to use palette[0]
uint8 gNoBGFillColor = 0xFF;
int MMC5Hack = 0;
int MMC5Hack = 0, PEC586Hack = 0;;
uint32 MMC5HackVROMMask = 0;
uint8 *MMC5HackExNTARAMPtr = 0;
uint8 *MMC5HackVROMPTR = 0;
@ -321,7 +321,6 @@ uint8 MMC50x5130 = 0;
uint8 MMC5HackSPScroll = 0;
uint8 MMC5HackSPPage = 0;
uint8 VRAMBuffer = 0, PPUGenLatch = 0;
uint8 *vnapage[4];
uint8 PPUNTARAM = 0;
@ -352,7 +351,6 @@ uint8 NTARAM[0x800], PALRAM[0x20], SPRAM[0x100], SPRBUF[0x100];
uint8 UPALRAM[0x03];//for 0x4/0x8/0xC addresses in palette, the ones in
//0x20 are 0 to not break fceu rendering.
#define MMC5SPRVRAMADR(V) &MMC5SPRVPage[(V) >> 10][(V)]
#define VRAMADR(V) &VPage[(V) >> 10][(V)]
@ -725,7 +723,6 @@ static DECLFR(A2007) {
}
} else {
ret = VRAMBuffer;
#ifdef FCEUDEF_DEBUGGER
if (!fceuindbg)
#endif
@ -740,13 +737,13 @@ static DECLFR(A2007) {
VRAMBuffer = vnapage[(tmp >> 10) & 0x3][tmp & 0x3FF];
}
}
#ifdef FCEUDEF_DEBUGGER
if (!fceuindbg)
#endif
{
if ((ScreenON || SpriteON) && (scanline < 240)) {
uint32 rad = RefreshAddr;
if ((rad & 0x7000) == 0x7000) {
rad ^= 0x7000;
if ((rad & 0x3E0) == 0x3A0)
@ -766,7 +763,6 @@ static DECLFR(A2007) {
}
if (PPU_hook) PPU_hook(RefreshAddr & 0x3fff);
}
return ret;
}
}
@ -819,8 +815,9 @@ static DECLFW(B2004) {
if (PPUSPL >= 8) {
if (PPU[3] >= 8)
SPRAM[PPU[3]] = V;
} else
} else {
SPRAM[PPUSPL] = V;
}
PPU[3]++;
PPUSPL++;
}
@ -1020,7 +1017,7 @@ static void RefreshLine(int lastpixel) {
// PPU_hook() functions can call
// mirroring/chr bank switching functions,
// which call FCEUPPU_LineUpdate, which call this
// function. */
// function.
if (norecurse) return;
if (sphitx != 0x100 && !(PPU_status & 0x40)) {
@ -1112,15 +1109,31 @@ static void RefreshLine(int lastpixel) {
else if (PPU_hook) {
norecurse = 1;
#define PPUT_HOOK
if (PEC586Hack) {
#define PPU_BGFETCH
for (X1 = firsttile; X1 < lasttile; X1++) {
#include "pputile.inc"
}
#undef PPU_BGFETCH
} else {
for (X1 = firsttile; X1 < lasttile; X1++) {
#include "pputile.inc"
}
}
#undef PPUT_HOOK
norecurse = 0;
} else {
if (PEC586Hack) {
#define PPU_BGFETCH
for (X1 = firsttile; X1 < lasttile; X1++) {
#include "pputile.inc"
}
#undef PPU_BGFETCH
} else {
for (X1 = firsttile; X1 < lasttile; X1++) {
#include "pputile.inc"
}
}
}
#undef vofs
@ -1302,12 +1315,12 @@ static void FetchSpriteData(void) {
ns = sb = 0;
vofs = (unsigned int)(P0 & 0x8 & (((P0 & 0x20) ^ 0x20) >> 2)) << 9;
vofs = (uint32)(P0 & 0x8 & (((P0 & 0x20) ^ 0x20) >> 2)) << 9;
H += (P0 & 0x20) >> 2;
if (!PPU_hook)
for (n = 63; n >= 0; n--, spr++) {
if ((unsigned int)(scanline - spr->y) >= H) continue;
if ((uint32)(scanline - spr->y) >= H) continue;
if (ns < maxsprites) {
if (n == 63) sb = 1;
@ -1315,7 +1328,7 @@ static void FetchSpriteData(void) {
SPRB dst;
uint8 *C;
int t;
unsigned int vadr;
uint32 vadr;
t = (int)scanline - (spr->y);
@ -1337,9 +1350,8 @@ static void FetchSpriteData(void) {
/* Fix this geniestage hack */
if (MMC5Hack && geniestage != 1)
C = MMC5SPRVRAMADR(vadr);
else {
else
C = VRAMADR(vadr);
}
if (SpriteON)
RENDER_LOG(vadr);
@ -1361,7 +1373,7 @@ static void FetchSpriteData(void) {
}
else
for (n = 63; n >= 0; n--, spr++) {
if ((unsigned int)(scanline - spr->y) >= H) continue;
if ((uint32)(scanline - spr->y) >= H) continue;
if (ns < maxsprites) {
if (n == 63) sb = 1;
@ -1370,7 +1382,7 @@ static void FetchSpriteData(void) {
SPRB dst;
uint8 *C;
int t;
unsigned int vadr;
uint32 vadr;
t = (int)scanline - (spr->y);
@ -1668,7 +1680,7 @@ void FCEUPPU_Power(void) {
BWrite[x + 2] = B2002;
ARead[x + 3] = A200x;
BWrite[x + 3] = B2003;
ARead[x + 4] = A2004; //A2004;
ARead[x + 4] = A2004;
BWrite[x + 4] = B2004;
ARead[x + 5] = A200x;
BWrite[x + 5] = B2005;
@ -1773,7 +1785,6 @@ int FCEUPPU_Loop(int skip) {
DEBUG(FCEUD_UpdatePPUView(scanline, 1));
DoLine();
}
if (MMC5Hack && (ScreenON || SpriteON)) MMC5_hb(scanline);
for (x = 1, max = 0, maxref = 0; x < 7; x++) {
if (deempcnt[x] > max) {
@ -1879,10 +1890,11 @@ void runppu(int x) {
//todo - consider making this a 3 or 4 slot fifo to keep from touching so much memory
struct BGData {
struct Record {
uint8 nt, at, pt[2];
uint8 nt, pecnt, at, pt[2];
INLINE void Read() {
RefreshAddr = ppur.get_ntread();
pecnt = (RefreshAddr & 1) << 3;
nt = CALL_PPUREAD(RefreshAddr);
runppu(kFetchTime);
@ -1906,6 +1918,14 @@ struct BGData {
ppur.par = nt;
RefreshAddr = ppur.get_ptread();
if (PEC586Hack) {
if (ScreenON)
RENDER_LOG(RefreshAddr | pecnt);
pt[0] = CALL_PPUREAD(RefreshAddr | pecnt);
runppu(kFetchTime);
pt[1] = CALL_PPUREAD(RefreshAddr | pecnt);
runppu(kFetchTime);
} else {
if (ScreenON)
RENDER_LOG(RefreshAddr);
pt[0] = CALL_PPUREAD(RefreshAddr);
@ -1916,6 +1936,7 @@ struct BGData {
pt[1] = CALL_PPUREAD(RefreshAddr);
runppu(kFetchTime);
}
}
};
Record main[34]; //one at the end is junk, it can never be rendered

View File

@ -3,7 +3,7 @@ register uint8 cc;
uint32 vadr;
#ifndef PPUT_MMC5SP
uint8 zz;
register uint8 zz;
#else
uint8 xs, ys;
xs = X1;
@ -18,7 +18,6 @@ if(X1>=2) {
pixdata = ppulut1[(pshift[0] >> (8 - XOffset)) & 0xFF] | ppulut2[(pshift[1] >> (8 - XOffset)) & 0xFF];
pixdata |= ppulut3[XOffset | (atlatch << 3)];
//printf("%02x ",ppulut3[XOffset|(atlatch<<3)]);
P[0] = S[pixdata & 0xF];
pixdata >>= 4;
@ -43,7 +42,7 @@ if(X1>=2) {
#else
zz = RefreshAddr & 0x1F;
C = vnapage[(RefreshAddr >> 10) & 3];
vadr=(C[RefreshAddr&0x3ff]<<4)+vofs; /* Fetch name table byte. */
vadr = (C[RefreshAddr & 0x3ff] << 4) + vofs; // Fetch name table byte.
#endif
#ifdef PPUT_HOOK
@ -57,7 +56,7 @@ if(X1>=2) {
#ifdef PPUT_MMC5CHR1
cc = (MMC5HackExNTARAMPtr[RefreshAddr & 0x3ff] & 0xC0) >> 6;
#else
cc=C[0x3c0+(zz>>2)+((RefreshAddr&0x380)>>4)]; /* Fetch attribute table byte. */
cc = C[0x3c0 + (zz >> 2) + ((RefreshAddr & 0x380) >> 4)]; // Fetch attribute table byte.
cc = ((cc >> ((zz & 2) + ((RefreshAddr & 0x40) >> 4))) & 3);
#endif
#endif
@ -74,8 +73,7 @@ pshift[1]<<=8;
#else
#ifdef PPUT_MMC5CHR1
C = MMC5HackVROMPTR;
C += (((MMC5HackExNTARAMPtr[RefreshAddr & 0x3ff]) & 0x3f &
MMC5HackVROMMask) << 12) + (vadr & 0xfff);
C += (((MMC5HackExNTARAMPtr[RefreshAddr & 0x3ff]) & 0x3f & MMC5HackVROMMask) << 12) + (vadr & 0xfff);
C += (MMC50x5130 & 0x3) << 18; //11-jun-2009 for kuja_killer
#elif defined(PPUT_MMC5)
C = MMC5BGVRAMADR(vadr);
@ -88,12 +86,26 @@ pshift[1]<<=8;
PPU_hook(vadr);
#endif
#ifdef PPU_BGFETCH
if (RefreshAddr & 1) {
if(ScreenON)
RENDER_LOG(vadr + 8);
pshift[0] |= C[8];
pshift[1] |= C[8];
} else {
if(ScreenON)
RENDER_LOG(vadr);
pshift[0] |= C[0];
pshift[1] |= C[0];
}
#else
if(ScreenON)
RENDER_LOG(vadr);
pshift[0] |= C[0];
if(ScreenON)
RENDER_LOG(vadr + 8);
pshift[1] |= C[8];
#endif
if ((RefreshAddr & 0x1f) == 0x1f)
RefreshAddr ^= 0x41F;

View File

@ -323,6 +323,7 @@
<ClCompile Include="..\src\boards\le05.cpp" />
<ClCompile Include="..\src\boards\lh32.cpp" />
<ClCompile Include="..\src\boards\lh53.cpp" />
<ClCompile Include="..\src\boards\mihunche.cpp" />
<ClCompile Include="..\src\boards\mmc2and4.cpp" />
<ClCompile Include="..\src\boards\onebus.cpp" />
<ClCompile Include="..\src\boards\pec-586.cpp" />

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="boards">
@ -955,6 +955,9 @@
<ClCompile Include="..\src\utils\ioapi.cpp">
<Filter>utils</Filter>
</ClCompile>
<ClCompile Include="..\src\boards\mihunche.cpp">
<Filter>boards</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\drivers\common\args.h">

View File

@ -1082,6 +1082,10 @@
RelativePath="..\src\boards\malee.cpp"
>
</File>
<File
RelativePath="..\src\boards\mihunche.cpp"
>
</File>
<File
RelativePath="..\src\boards\mmc1.cpp"
>

View File

@ -851,6 +851,10 @@
RelativePath="..\src\boards\lh53.cpp"
>
</File>
<File
RelativePath="..\src\boards\mihunche.cpp"
>
</File>
<File
RelativePath="..\src\boards\malee.cpp"
>