X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=boards%2Fmmc1.c;h=24a07bc828f76965e5bb697a45101d7396a571aa;hb=386f5371eb984fb9c2860c83e740890a75cd45c1;hp=0eefc5943165a9f401c96dcc9df8beb7f7d708c3;hpb=d97315ac0bca825d2d50a44453bc5652946e2c67;p=fceu.git diff --git a/boards/mmc1.c b/boards/mmc1.c index 0eefc59..24a07bc 100644 --- a/boards/mmc1.c +++ b/boards/mmc1.c @@ -16,7 +16,7 @@ * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mapinc.h" @@ -34,7 +34,7 @@ static void (*MMC1PRGHook16)(uint32 A, uint8 V); static uint8 *WRAM=NULL; static uint8 *CHRRAM=NULL; -static int is155; +static int is155, is171; static DECLFW(MBWRAM) { @@ -58,6 +58,7 @@ static void MMC1CHR(void) else setprg8r(0x10,0x6000,(DRegs[1]>>3)&1); } + if(MMC1CHRHook4) { if(DRegs[0]&0x10) @@ -86,7 +87,6 @@ static void MMC1CHR(void) static void MMC1PRG(void) { uint8 offs=DRegs[1]&0x10; - if(MMC1PRGHook16) { switch(DRegs[0]&0xC) @@ -104,7 +104,9 @@ static void MMC1PRG(void) break; } } - else switch(DRegs[0]&0xC) + else + { + switch(DRegs[0]&0xC) { case 0xC: setprg16(0x8000,(DRegs[3]+offs)); setprg16(0xC000,0xF+offs); @@ -119,9 +121,11 @@ static void MMC1PRG(void) break; } } +} static void MMC1MIRROR(void) { + if(!is171) switch(DRegs[0]&3) { case 2: setmirror(MI_V); break; @@ -131,22 +135,23 @@ static void MMC1MIRROR(void) } } - static uint64 lreset; static DECLFW(MMC1_write) { int n=(A>>13)-4; - //FCEU_DispMessage("%016x",timestampbase+timestamp); - //printf("$%04x:$%02x, $%04x\n",A,V,X.PC); + //FCEU_DispMessage("%016x",0,timestampbase+timestamp); +// FCEU_printf("$%04x:$%02x, $%04x\n",A,V,X.PC); //DumpMem("out",0xe000,0xffff); /* The MMC1 is busy so ignore the write. */ /* As of version FCE Ultra 0.81, the timestamp is only increased before each instruction is executed(in other words precision isn't that great), but this should still work to - deal with 2 writes in a row from a single RMW instruction. */ - if((timestampbase+timestamp)<(lreset+2)) return; - + deal with 2 writes in a row from a single RMW instruction. + */ + if((timestampbase+timestamp)<(lreset+2)) + return; +// FCEU_printf("Write %04x:%02x\n",A,V); if(V&0x80) { DRegs[0]|=0xC; @@ -155,7 +160,9 @@ static DECLFW(MMC1_write) lreset=timestampbase+timestamp; return; } + Buffer|=(V&1)<<(BufferShift++); + if(BufferShift==5) { DRegs[n] = Buffer; @@ -175,16 +182,18 @@ static void MMC1_Restore(int version) MMC1MIRROR(); MMC1CHR(); MMC1PRG(); - //lreset=0; /* timestamp(base) is not stored in save states. */ // it is now! + lreset=0; /* timestamp(base) is not stored in save states. */ } static void MMC1CMReset(void) { int i; + for(i=0;i<4;i++) DRegs[i]=0; Buffer = BufferShift = 0; DRegs[0]=0x1F; + DRegs[1]=0; DRegs[2]=0; // Should this be something other than 0? DRegs[3]=0; @@ -203,6 +212,8 @@ static int DetectMMC1WRAMSize(uint32 crc32) case 0x4642dda6: /* Nobunaga's Ambition */ case 0x29449ba9: /* "" "" (J) */ case 0x2b11e0b0: /* "" "" (J) */ + case 0xb8747abf: /* Best Play Pro Yakyuu Special (J) */ + case 0xc9556b36: /* Final Fantasy I & II (J) [!] */ FCEU_printf(" >8KB external WRAM present. Use UNIF if you hack the ROM image.\n"); return(16); break; @@ -214,7 +225,7 @@ static uint32 NWCIRQCount; static uint8 NWCRec; #define NWCDIP 0xE -static void FP_FASTAPASS(1) NWCIRQHook(int a) +static void NWCIRQHook(int a) { if(!(NWCRec&0x10)) { @@ -234,6 +245,7 @@ static void NWCCHRHook(uint32 A, uint8 V) NWCIRQCount=0; X6502_IRQEnd(FCEU_IQEXT); } + NWCRec=V; if(V&0x08) MMC1PRG(); @@ -311,6 +323,11 @@ static void GenMMC1Init(CartInfo *info, int prg, int chr, int wram, int battery) if(wram) { WRAM=(uint8*)FCEU_gmalloc(wram*1024); + //mbg 17-jun-08 - this shouldve been cleared to re-initialize save ram + //ch4 10-dec-08 - nope, this souldn't + //mbg 29-mar-09 - no time to debate this, we need to keep from breaking some old stuff. + //we really need to make up a policy for how compatibility and accuracy can be resolved. + memset(WRAM,0,wram*1024); mmc1opts|=1; if(wram>8) mmc1opts|=4; SetupCartPRGMapping(0x10,WRAM,wram*1024,1); @@ -350,6 +367,14 @@ void Mapper155_Init(CartInfo *info) is155=1; } +/* Same as mapper 1, with different (or without) mirroring control. */ +/* Kaiser KS7058 board, KS203 custom chip */ +void Mapper171_Init(CartInfo *info) +{ + GenMMC1Init(info,32,32,0,0); + is171=1; +} + void SAROM_Init(CartInfo *info) { GenMMC1Init(info, 128, 64, 8, info->battery);