first batch of changes

[[Split portion of a mixed commit.]]
This commit is contained in:
zeromus 2006-07-18 03:58:09 +00:00
parent dfd763c100
commit d5ffacea03
159 changed files with 395 additions and 15443 deletions

View File

@ -1,90 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static uint8 reg[8];
static uint8 mirror, cmd;
static uint8 *WRAM=NULL;
static SFORMAT StateRegs[]=
{
{&cmd, 1, "CMD"},
{&mirror, 1, "MIRR"},
{reg, 8, "REGS"},
{0}
};
static void Sync(void)
{
setmirror(mirror^1);
setprg8(0x8000,reg[0]);
setprg8(0xA000,reg[1]);
setchr2(0x0000,reg[2]>>1);
setchr2(0x0800,reg[3]>>1);
setchr1(0x1000,reg[4]);
setchr1(0x1400,reg[5]);
setchr1(0x1800,reg[6]);
setchr1(0x1C00,reg[7]);
}
static DECLFW(M112Write)
{
switch(A)
{
case 0xe000: mirror=V&1; Sync(); ;break;
case 0x8000: cmd=V&7; break;
case 0xa000: reg[cmd]=V; Sync(); break;
}
FCEU_printf("%04x:%04x %d\n",A,V,scanline);
}
static void M112Close(void)
{
if(WRAM)
FCEU_gfree(WRAM);
WRAM = NULL;
}
static void M112Power(void)
{
setprg16(0xC000,~0);
setprg8r(0x10,0x6000,0);
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x8000,0xFFFF,M112Write);
SetReadHandler(0x6000,0x7FFF,CartBR);
SetWriteHandler(0x6000,0x7FFF,CartBW);
}
static void StateRestore(int version)
{
Sync();
}
void Mapper112_Init(CartInfo *info)
{
info->Power=M112Power;
info->Close=M112Close;
GameStateRestore=StateRestore;
WRAM=(uint8*)FCEU_gmalloc(8192);
SetupCartPRGMapping(0x10,WRAM,8192,1);
AddExState(WRAM, 8192, 0, "WRAM");
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,101 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static uint8 prgreg[4], chrreg[8];
static uint8 IRQa, IRQCount, IRQLatch;
static SFORMAT StateRegs[]=
{
{&IRQa, 1, "IRQA"},
{&IRQCount, 1, "IRQC"},
{&IRQLatch, 1, "IRQL"},
{prgreg, 4, "PREGS"},
{chrreg, 8, "CREGS"},
{0}
};
static void Sync(void)
{
setprg8(0x8000,prgreg[0]);
setprg8(0xa000,prgreg[1]);
setprg8(0xc000,prgreg[2]);
setprg8(0xe000,prgreg[3]);
int i;
for(i=0; i<8; i++)
setchr1(i<<10,chrreg[i]);
}
static DECLFW(M117Write)
{
if(A<0x8004)
{
prgreg[A&3]=V;
Sync();
}
else if((A>=0xA000)&&(A<=0xA007))
{
chrreg[A&7]=V;
Sync();
}
else switch(A)
{
case 0xc001: IRQLatch=V; break;
case 0xc003: IRQCount=IRQLatch; IRQa|=2; break;
case 0xe000: IRQa&=~1; IRQa|=V&1; X6502_IRQEnd(FCEU_IQEXT); break;
case 0xc002: X6502_IRQEnd(FCEU_IQEXT); break;
}
}
static void M117Power(void)
{
prgreg[0]=~3; prgreg[1]=~2; prgreg[2]=~1; prgreg[3]=~0;
Sync();
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x8000,0xFFFF,M117Write);
}
static void M117IRQHook(void)
{
if(IRQa==3&&IRQCount)
{
IRQCount--;
if(!IRQCount)
{
IRQa&=1;
X6502_IRQBegin(FCEU_IQEXT);
}
}
}
static void StateRestore(int version)
{
Sync();
}
void Mapper117_Init(CartInfo *info)
{
info->Power=M117Power;
GameHBIRQHook=M117IRQHook;
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,116 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static uint8 cmd;
static uint8 DRegs[8];
static SFORMAT StateRegs[]=
{
{&cmd, 1, "CMD"},
{DRegs, 8, "DREG"},
{0}
};
static void Sync(void)
{
setprg32(0x8000,(DRegs[0]<<4)|(DRegs[1]&0xF));
setchr8(0);
}
static void StateRestore(int version)
{
Sync();
}
static DECLFW(Write)
{
switch (A&0x7300)
{
case 0x5100: DRegs[0]=V; Sync(); break;
case 0x5000: DRegs[1]=V; Sync(); break;
}
}
static DECLFW(Write2)
{
switch (A&0x7300)
{
case 0x5200: DRegs[0]=V; Sync(); break;
case 0x5000: DRegs[1]=V; Sync(); break;
}
}
static uint8 WRAM[8192];
static DECLFR(AWRAM)
{
return(WRAM[A-0x6000]);
}
static DECLFW(BWRAM)
{
WRAM[A-0x6000]=V;
}
static void Power(void)
{
memset(DRegs,0,8);
DRegs[1]=0xFF;
cmd=0;
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x4020,0xFFFF,Write);
SetReadHandler(0x6000,0x7FFF,AWRAM);
SetWriteHandler(0x6000,0x7FFF,BWRAM);
Sync();
}
static void M163HB(void)
{
if(scanline==127&&DRegs[1]&0x80)
setchr4(0x0000,1);
}
static void Power2(void)
{
memset(DRegs,0,8);
DRegs[1]=0xFF;
cmd=0;
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x4020,0xFFFF,Write2);
SetReadHandler(0x6000,0x7FFF,AWRAM);
SetWriteHandler(0x6000,0x7FFF,BWRAM);
Sync();
}
void Mapper164_Init(CartInfo *info)
{
info->Power=Power;
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}
void Mapper163_Init(CartInfo *info)
{
info->Power=Power2;
GameHBIRQHook=M163HB;
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,117 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Gimmick Bootleg
*/
#include "mapinc.h"
static uint8 prg[4];
static uint8 chr[8];
static uint8 IRQCount;
static uint8 IRQPre;
static uint8 IRQa;
static SFORMAT StateRegs[]=
{
{prg, 4, "PRG"},
{chr, 8, "CHR"},
{&IRQCount, 1, "IRQCOUNT"},
{&IRQPre, 1, "IRQPRE"},
{&IRQa, 1, "IRQA"},
{0}
};
static void SyncPrg(void)
{
setprg8(0x6000,0);
setprg8(0x8000,prg[0]);
setprg8(0xA000,prg[1]);
setprg8(0xC000,prg[2]);
setprg8(0xE000,~0);
}
static void SyncChr(void)
{
int i;
for(i=0; i<8; i++)
setchr1(i<<10,chr[i]);
}
static void StateRestore(int version)
{
SyncPrg();
SyncChr();
}
static DECLFW(M183Write)
{
if(((A&0xF80C)>=0xB000)&&((A&0xF80C)<=0xE00C))
{
uint8 index=(((A&0x7000)>>11)-6)|((A&8)>>3);
chr[index]=(chr[index]&(0xF0>>(A&4)))|((V&0x0F)<<(A&4));
SyncChr();
}
else switch (A&0xF80C)
{
case 0x8800: prg[0]=V; SyncPrg(); break;
case 0xA800: prg[1]=V; SyncPrg(); break;
case 0xA000: prg[2]=V; SyncPrg(); break;
case 0x9800: switch (V&3)
{
case 0: setmirror(MI_V); break;
case 1: setmirror(MI_H); break;
case 2: setmirror(MI_0); break;
case 3: setmirror(MI_1); break;
}
break;
case 0xF000: IRQCount=((IRQCount&0xF0)|(V&0xF)); break;
case 0xF004: IRQCount=((IRQCount&0x0F)|((V&0xF)<<4)); break;
case 0xF008: IRQa=V; if(!V)IRQPre=0; X6502_IRQEnd(FCEU_IQEXT); break;
case 0xF00C: IRQPre=16; break;
}
}
static void M183IRQCounter(void)
{
if(IRQa)
{
IRQCount++;
if((IRQCount-IRQPre)==238)
X6502_IRQBegin(FCEU_IQEXT);
}
}
static void M183Power(void)
{
IRQPre=IRQCount=IRQa=0;
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x8000,0xFFFF,M183Write);
SetReadHandler(0x6000,0x7FFF,CartBR);
SyncPrg();
SyncChr();
}
void Mapper183_Init(CartInfo *info)
{
info->Power=M183Power;
GameHBIRQHook=M183IRQCounter;
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,116 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Family Study Box by Fukutake Shoten
*/
#include "mapinc.h"
static uint8 *DummyCHR=NULL;
static uint8 datareg;
static void(*Sync)(void);
static SFORMAT StateRegs[]=
{
{&datareg, 1, "DREG"},
{0}
};
// on off
//1 0x0F, 0xF0 - Bird Week
//2 0x33, 0x00 - B-Wings
//3 0x11, 0x00 - Mighty Bomb Jack
//4 0x22, 0x20 - Sansuu 1 Nen, Sansuu 2 Nen
//5 0xFF, 0x00 - Sansuu 3 Nen
//6 0x21, 0x13 - Spy vs Spy
//7 0x20, 0x21 - Seicross
static void Sync185(void)
{
// little dirty eh? ;_)
if((datareg&3)&&(datareg!=0x13)) // 1, 2, 3, 4, 5, 6
setchr8(0);
else
setchr8r(0x10,0);
}
static void Sync181(void)
{
if(!(datareg&1)) // 7
setchr8(0);
else
setchr8r(0x10,0);
}
static DECLFW(MWrite)
{
datareg=V;
Sync();
}
static void MPower(void)
{
datareg=0;
Sync();
setprg16(0x8000,0);
setprg16(0xC000,~0);
SetWriteHandler(0x8000,0xFFFF,MWrite);
SetReadHandler(0x8000,0xFFFF,CartBR);
}
static void MClose(void)
{
if(DummyCHR)
FCEU_gfree(DummyCHR);
DummyCHR=NULL;
}
static void MRestore(int version)
{
Sync();
}
void Mapper185_Init(CartInfo *info)
{
Sync=Sync185;
info->Power=MPower;
info->Close=MClose;
GameStateRestore=MRestore;
DummyCHR=(uint8*)FCEU_gmalloc(8192);
int x;
for(x=0;x<8192;x++)
DummyCHR[x]=0xff;
SetupCartCHRMapping(0x10,DummyCHR,8192,0);
AddExState(StateRegs, ~0, 0, 0);
}
void Mapper181_Init(CartInfo *info)
{
Sync=Sync181;
info->Power=MPower;
info->Close=MClose;
GameStateRestore=MRestore;
DummyCHR=(uint8*)FCEU_gmalloc(8192);
int x;
for(x=0;x<8192;x++)
DummyCHR[x]=0xff;
SetupCartCHRMapping(0x10,DummyCHR,8192,0);
AddExState(StateRegs, ~0, 0, 0);
}

View File

@ -1,104 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Family Study Box by Fukutake Shoten
*/
#include "mapinc.h"
static uint8 SWRAM[2816];
static uint8 *WRAM=NULL;
static uint8 regs[4];
static SFORMAT StateRegs[]=
{
{regs, 4, "DREG"},
{SWRAM, 2816, "SWRAM"},
{0}
};
static void Sync(void)
{
setprg8r(0x10,0x6000,regs[0]>>6);
setprg16(0x8000,regs[1]);
setprg16(0xc000,0);
}
static DECLFW(M186Write)
{
if(A&0x4203) regs[A&3]=V;
Sync();
}
static DECLFR(M186Read)
{
switch(A)
{
case 0x4200: return 0x00; break;
case 0x4201: return 0x00; break;
case 0x4202: return 0x40; break;
case 0x4203: return 0x00; break;
}
return 0xFF;
}
static DECLFR(ASWRAM)
{
return(SWRAM[A-0x4400]);
}
static DECLFW(BSWRAM)
{
SWRAM[A-0x4400]=V;
}
static void M186Power(void)
{
setchr8(0);
SetReadHandler(0x6000,0xFFFF,CartBR);
SetWriteHandler(0x6000,0xFFFF,CartBW);
SetReadHandler(0x4200,0x43FF,M186Read);
SetWriteHandler(0x4200,0x43FF,M186Write);
SetReadHandler(0x4400,0x4EFF,ASWRAM);
SetWriteHandler(0x4400,0x4EFF,BSWRAM);
regs[0]=regs[1]=regs[2]=regs[3];
Sync();
}
static void M186Close(void)
{
if(WRAM)
FCEU_gfree(WRAM);
WRAM=NULL;
}
static void M186Restore(int version)
{
Sync();
}
void Mapper186_Init(CartInfo *info)
{
info->Power=M186Power;
info->Close=M186Close;
GameStateRestore=M186Restore;
WRAM=(uint8*)FCEU_gmalloc(32384);
SetupCartPRGMapping(0x10,WRAM,32384,1);
AddExState(WRAM, 32384, 0, "WRAM");
AddExState(StateRegs, ~0, 0, 0);
}

View File

@ -1,104 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
#include "mmc3.h"
static void M187CW(uint32 A, uint8 V)
{
if((A&0x1000)==((MMC3_cmd&0x80)<<5))
setchr1(A,V|0x100);
else
setchr1(A,V);
}
static void M187PW(uint32 A, uint8 V)
{
if(EXPREGS[0]&0x80)
{
uint8 bank=EXPREGS[0]&0x1F;
if(EXPREGS[0]&0x20)
setprg32(0x8000,bank>>2);
else
{
setprg16(0x8000,bank);
setprg16(0xC000,bank);
}
}
else
setprg8(A,V&0x3F);
}
static DECLFW(M187Write8000)
{
EXPREGS[2]=1;
MMC3_CMDWrite(A,V);
}
static DECLFW(M187Write8001)
{
if(EXPREGS[2])
MMC3_CMDWrite(A,V);
}
static DECLFW(M187Write8003)
{
EXPREGS[2]=0;
if(V==0x28)setprg8(0xC000,0x17);
else if(V==0x2A)setprg8(0xA000,0x0F);
}
static DECLFW(M187WriteLo)
{
EXPREGS[1]=V;
if(A==0x5000)
{
EXPREGS[0]=V;
FixMMC3PRG(MMC3_cmd);
}
}
static uint8 prot_data[4] = { 0x83, 0x83, 0x42, 0x00 };
static DECLFR(M187Read)
{
return prot_data[EXPREGS[1]&3];
}
static void M187Power(void)
{
EXPREGS[0]=EXPREGS[1]=EXPREGS[2]=0;
GenMMC3Power();
Write_IRQFM(0x4017,0x40);
SetReadHandler(0x5000,0x5FFF,M187Read);
SetWriteHandler(0x5000,0x5FFF,M187WriteLo);
SetWriteHandler(0x8000,0x8000,M187Write8000);
SetWriteHandler(0x8001,0x8001,M187Write8001);
SetWriteHandler(0x8003,0x8003,M187Write8003);
}
void Mapper187_Init(CartInfo *info)
{
GenMMC3_Init(info, 256, 256, 0, 0);
pwrap=M187PW;
cwrap=M187CW;
info->Power=M187Power;
AddExState(EXPREGS, 3, 0, "EXPR");
}

View File

@ -1,48 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
#include "mmc3.h"
static void M189PW(uint32 A, uint8 V)
{
setprg32(0x8000,EXPREGS[0]&3);
}
static DECLFW(M189Write)
{
EXPREGS[0]=V|(V>>4); //actually, there is a two versions of 189 mapper with hi or lo bits bankswitching.
FixMMC3PRG(MMC3_cmd);
}
static void M189Power(void)
{
EXPREGS[0]=EXPREGS[1]=0;
GenMMC3Power();
SetWriteHandler(0x4120,0x7FFF,M189Write);
}
void Mapper189_Init(CartInfo *info)
{
GenMMC3_Init(info, 256, 256, 0, 0);
pwrap=M189PW;
info->Power=M189Power;
AddExState(EXPREGS, 2, 0, "EXPR");
}

View File

@ -1,83 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
#include "mmc3.h"
static 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,
0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x51, 0x41, 0x11, 0x01, 0x51, 0x41, 0x11, 0x01,
0x00, 0x10, 0x40, 0x50, 0x00, 0x10, 0x40, 0x50,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x18, 0x48, 0x58, 0x08, 0x18, 0x48, 0x58,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x10, 0x40, 0x50, 0x00, 0x10, 0x40, 0x50,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x18, 0x48, 0x58, 0x08, 0x18, 0x48, 0x58,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x58, 0x48, 0x18, 0x08, 0x58, 0x48, 0x18, 0x08,
0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x50, 0x40, 0x10, 0x00, 0x50, 0x40, 0x10, 0x00,
0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x58, 0x48, 0x18, 0x08, 0x58, 0x48, 0x18, 0x08,
0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x50, 0x40, 0x10, 0x00, 0x50, 0x40, 0x10, 0x00,
0x01, 0x11, 0x41, 0x51, 0x01, 0x11, 0x41, 0x51,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x09, 0x19, 0x49, 0x59, 0x09, 0x19, 0x49, 0x59,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x11, 0x41, 0x51, 0x01, 0x11, 0x41, 0x51,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x09, 0x19, 0x49, 0x59, 0x09, 0x19, 0x49, 0x59,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
static void M208PW(uint32 A, uint8 V)
{
setprg32(0x8000,EXPREGS[5]);
}
static DECLFW(M208Write)
{
EXPREGS[5]=(V&0x1)|((V>>3)&0x2);
FixMMC3PRG(MMC3_cmd);
}
static DECLFW(M208ProtWrite)
{
if(A<=0x57FF)
EXPREGS[4]=V;
else
EXPREGS[(A&0x03)]=V^lut[EXPREGS[4]];
}
static DECLFR(M208ProtRead)
{
return(EXPREGS[(A&0x3)]);
}
static void M208Power(void)
{
EXPREGS[5]=3;
GenMMC3Power();
SetWriteHandler(0x4800,0x4FFF,M208Write);
SetWriteHandler(0x5000,0x5fff,M208ProtWrite);
SetReadHandler(0x5800,0x5FFF,M208ProtRead);
SetReadHandler(0x8000,0xffff,CartBR);
}
void Mapper208_Init(CartInfo *info)
{
GenMMC3_Init(info, 128, 256, 0, 0);
pwrap=M208PW;
info->Power=M208Power;
AddExState(EXPREGS, 6, 0, "EXPR");
}

View File

@ -1,99 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "mapinc.h"
static uint16 IRQCount;
static uint8 IRQa;
static uint8 prg_reg[2];
static uint8 chr_reg[8];
static SFORMAT StateRegs[]=
{
{&IRQCount, 2, "IRQC"},
{&IRQa, 2, "IRQA"},
{prg_reg, 2, "PRG"},
{chr_reg, 8, "CHR"},
{0}
};
static void M222IRQ(void)
{
if(IRQa)
{
IRQCount++;
if(IRQCount>=240)
{
X6502_IRQBegin(FCEU_IQEXT);
IRQa=0;
}
}
}
static void Sync(void)
{
setprg8(0x8000,prg_reg[0]);
setprg8(0xA000,prg_reg[1]);
int i;
for(i=0; i<8; i++)
setchr1(i<<10,chr_reg[i]);
}
static DECLFW(M222Write)
{
switch(A&0xF003)
{
case 0x8000: prg_reg[0]=V; break;
case 0xA000: prg_reg[1]=V; break;
case 0xB000: chr_reg[0]=V; break;
case 0xB002: chr_reg[1]=V; break;
case 0xC000: chr_reg[2]=V; break;
case 0xC002: chr_reg[3]=V; break;
case 0xD000: chr_reg[4]=V; break;
case 0xD002: chr_reg[5]=V; break;
case 0xE000: chr_reg[6]=V; break;
case 0xE002: chr_reg[7]=V; break;
case 0xF000: IRQCount=IRQa=V;
X6502_IRQEnd(FCEU_IQEXT);
break;
}
Sync();
}
static void M222Power(void)
{
setprg16(0xC000,~0);
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x8000,0xFFFF,M222Write);
}
static void StateRestore(int version)
{
Sync();
}
void Mapper222_Init(CartInfo *info)
{
info->Power=M222Power;
GameHBIRQHook=M222IRQ;
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,70 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static uint16 cmdreg;
static SFORMAT StateRegs[]=
{
{&cmdreg, 2, "CMDREG"},
{0}
};
static void Sync(void)
{
if(cmdreg&0x400)
setmirror(MI_0);
else
setmirror(((cmdreg>>13)&1)^1);
if(cmdreg&0x800)
{
setprg16(0x8000,((cmdreg&0x300)>>3)|((cmdreg&0x1F)<<1)|((cmdreg>>12)&1));
setprg16(0xC000,((cmdreg&0x300)>>3)|((cmdreg&0x1F)<<1)|((cmdreg>>12)&1));
}
else
setprg32(0x8000,((cmdreg&0x300)>>4)|(cmdreg&0x1F));
}
static DECLFW(M235Write)
{
cmdreg=A;
Sync();
}
static void M235Power(void)
{
setchr8(0);
SetWriteHandler(0x8000,0xFFFF,M235Write);
SetReadHandler(0x8000,0xFFFF,CartBR);
cmdreg=0;
Sync();
}
static void M235Restore(int version)
{
Sync();
}
void Mapper235_Init(CartInfo *info)
{
info->Power=M235Power;
GameStateRestore=M235Restore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,93 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "mapinc.h"
static uint8 prg_reg;
static uint8 chr_reg;
static uint8 hrd_flag;
static SFORMAT StateRegs[]=
{
{&prg_reg, 1, "PRG"},
{&chr_reg, 1, "CHR"},
{0}
};
static void Sync(void)
{
if(prg_reg&0x80)
setprg32(0x8000,prg_reg>>6);
else
{
setprg16(0x8000,(prg_reg>>5)&3);
setprg16(0xC000,(prg_reg>>5)&3);
}
setmirror((prg_reg&8)>>3);
setchr8((chr_reg&3)|(prg_reg&7)|((prg_reg&0x10)>>1));
}
static DECLFR(M57Read)
{
return hrd_flag;
}
static DECLFW(M57Write)
{
if((A&0x8800)==0x8800)
prg_reg=V;
else
chr_reg=V;
Sync();
}
static void M57Power(void)
{
prg_reg=0;
chr_reg=0;
hrd_flag=0;
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x8000,0xFFFF,M57Write);
SetReadHandler(0x6000,0x6000,M57Read);
Sync();
}
static void M57Reset()
{
if(hrd_flag==3)
hrd_flag=0;
else
hrd_flag++;
FCEU_printf("Select Register = %02x\n",hrd_flag);
}
static void StateRestore(int version)
{
Sync();
}
void Mapper57_Init(CartInfo *info)
{
info->Power=M57Power;
info->Reset=M57Reset;
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,80 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static uint16 cmdreg;
static uint8 invalid_data;
static SFORMAT StateRegs[]=
{
{&cmdreg, 2, "CMDREG"},
{0}
};
static void Sync(void)
{
setprg16r((cmdreg&0x060)>>5,0x8000,(cmdreg&0x01C)>>2);
setprg16r((cmdreg&0x060)>>5,0xC000,(cmdreg&0x200)?(~0):0);
setmirror(((cmdreg&2)>>1)^1);
}
static DECLFR(UNL8157Read)
{
if(invalid_data&&cmdreg&0x100)
return 0xFF;
else
return CartBR(A);
}
static DECLFW(UNL8157Write)
{
cmdreg=A;
Sync();
}
static void UNL8157Power(void)
{
setchr8(0);
SetWriteHandler(0x8000,0xFFFF,UNL8157Write);
SetReadHandler(0x8000,0xFFFF,UNL8157Read);
cmdreg=0x200;
invalid_data=1;
Sync();
}
static void UNL8157Reset(void)
{
cmdreg=0;
invalid_data^=1;
Sync();
}
static void UNL8157Restore(int version)
{
Sync();
}
void UNL8157_Init(CartInfo *info)
{
info->Power=UNL8157Power;
info->Reset=UNL8157Reset;
GameStateRestore=UNL8157Restore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,93 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
#include "mmc3.h"
static uint8 cmdin;
static uint8 UNL8237_perm[8] = {0, 2, 6, 1, 7, 3, 4, 5};
static void UNL8237CW(uint32 A, uint8 V)
{
setchr1(A,((EXPREGS[1]&4)<<6)|V);
}
static void UNL8237PW(uint32 A, uint8 V)
{
if(EXPREGS[0]&0x80)
{
if(EXPREGS[0]&0x20)
setprg32(0x8000,(EXPREGS[0]&0xF)>>1);
else
{
setprg16(0x8000,(EXPREGS[0]&0x1F));
setprg16(0xC000,(EXPREGS[0]&0x1F));
}
}
else
setprg8(A,V&0x3F);
}
static DECLFW(UNL8237Write)
{
if((A&0xF000)==0xF000)
IRQCount=V;
else if((A&0xF000)==0xE000)
X6502_IRQEnd(FCEU_IQEXT);
else switch(A&0xE001)
{
case 0x8000: setmirror(((V|(V>>7))&1)^1); break;
case 0xA000: MMC3_CMDWrite(0x8000,(V&0xC0)|(UNL8237_perm[V&7])); cmdin=1; break;
case 0xC000: if(cmdin)
{
MMC3_CMDWrite(0x8001,V);
cmdin=0;
}
break;
}
}
static DECLFW(UNL8237ExWrite)
{
switch(A)
{
case 0x5000: EXPREGS[0]=V; FixMMC3PRG(MMC3_cmd); break;
case 0x5001: EXPREGS[1]=V; FixMMC3CHR(MMC3_cmd); break;
}
}
static void UNL8237Power(void)
{
IRQa=1;
EXPREGS[0]=EXPREGS[1]=0;
GenMMC3Power();
SetWriteHandler(0x8000,0xFFFF,UNL8237Write);
SetWriteHandler(0x5000,0x7FFF,UNL8237ExWrite);
}
void UNL8237_Init(CartInfo *info)
{
GenMMC3_Init(info, 256, 256, 0, 0);
cwrap=UNL8237CW;
pwrap=UNL8237PW;
info->Power=UNL8237Power;
AddExState(EXPREGS, 3, 0, "EXPR");
AddExState(&cmdin, 1, 0, "CMDIN");
}

View File

@ -1,87 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static uint8 reg[8];
static uint8 mirror, cmd, is154;
static SFORMAT StateRegs[]=
{
{&cmd, 1, "CMD"},
{&mirror, 1, "MIRR"},
{reg, 8, "REGS"},
{0}
};
static void Sync(void)
{
setchr2(0x0000,reg[0]>>1);
setchr2(0x0800,reg[1]>>1);
setchr1(0x1000,reg[2]|0x40);
setchr1(0x1400,reg[3]|0x40);
setchr1(0x1800,reg[4]|0x40);
setchr1(0x1C00,reg[5]|0x40);
setprg8(0x8000,reg[6]);
setprg8(0xA000,reg[7]);
}
static void MSync(void)
{
if(is154)setmirror(MI_0+(mirror&1));
}
static DECLFW(M88Write)
{
switch(A&0x8001)
{
case 0x8000: cmd=V&7; mirror=V>>6; MSync(); break;
case 0x8001: reg[cmd]=V; Sync(); break;
}
}
static void M88Power(void)
{
setprg16(0xC000,~0);
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x8000,0xFFFF,M88Write);
}
static void StateRestore(int version)
{
Sync();
MSync();
}
void Mapper88_Init(CartInfo *info)
{
is154=0;
info->Power=M88Power;
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}
void Mapper154_Init(CartInfo *info)
{
is154=1;
info->Power=M88Power;
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,466 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
//#define DEBUG90
static int is209;
static int is211;
static uint8 IRQMode; // from $c001
static uint8 IRQPre; // from $c004
static uint8 IRQPreSize; // from $c007
static uint8 IRQCount; // from $c005
static uint8 IRQXOR; // Loaded from $C006
static uint8 IRQa; // $c002, $c003, and $c000
static uint8 mul[2];
static uint8 regie;
static uint8 tkcom[4];
static uint8 prgb[4];
static uint8 chrlow[8];
static uint8 chrhigh[8];
static uint16 names[4];
static uint8 tekker;
static SFORMAT Tek_StateRegs[]={
{&IRQMode, 1, "IRQMODE"},
{&IRQPre, 1, "IRQPRE"},
{&IRQPreSize, 1, "IRQPRESIZE"},
{&IRQCount, 1, "IRQC"},
{&IRQXOR, 1, "IRQXOR"},
{&IRQa, 1, "IRQa"},
{mul, 2, "MUL"},
{&regie, 1, "REGI"},
{tkcom, 4, "TKCO"},
{prgb, 4, "PRGB"},
{chrlow, 4, "CHRL"},
{chrhigh, 8, "CHRH"},
{&names[0], 2|FCEUSTATE_RLSB, "NMS0"},
{&names[1], 2|FCEUSTATE_RLSB, "NMS1"},
{&names[2], 2|FCEUSTATE_RLSB, "NMS2"},
{&names[3], 2|FCEUSTATE_RLSB, "NMS3"},
{&tekker, 1, "TEKR"},
{0}
};
static void mira(void)
{
if((tkcom[0]&0x20&&is209)||is211)
{
int x;
if(tkcom[0]&0x40) // Name tables are ROM-only
{
for(x=0;x<4;x++)
setntamem(CHRptr[0]+(((names[x])&CHRmask1[0])<<10),0,x);
}
else // Name tables can be RAM or ROM.
{
for(x=0;x<4;x++)
{
if((tkcom[1]&0x80)==(names[x]&0x80)) // RAM selected.
setntamem(NTARAM+((names[x]&0x1)<<10),1,x);
else
setntamem(CHRptr[0]+(((names[x])&CHRmask1[0])<<10),0,x);
}
}
}
else
{
switch(tkcom[1]&3)
{
case 0: setmirror(MI_V); break;
case 1: setmirror(MI_H); break;
case 2: setmirror(MI_0); break;
case 3: setmirror(MI_1); break;
}
}
}
static void tekprom(void)
{
uint32 bankmode=((tkcom[3]&6)<<5);
switch(tkcom[0]&7)
{
case 00: if(tkcom[0]&0x80)
setprg8(0x6000,(((prgb[3]<<2)+3)&0x3F)|bankmode);
setprg32(0x8000,0x0F|((tkcom[3]&6)<<3));
break;
case 01: if(tkcom[0]&0x80)
setprg8(0x6000,(((prgb[3]<<1)+1)&0x3F)|bankmode);
setprg16(0x8000,(prgb[1]&0x1F)|((tkcom[3]&6)<<4));
setprg16(0xC000,0x1F|((tkcom[3]&6)<<4));
break;
case 03: // bit reversion
case 02: if(tkcom[0]&0x80)
setprg8(0x6000,(prgb[3]&0x3F)|bankmode);
setprg8(0x8000,(prgb[0]&0x3F)|bankmode);
setprg8(0xa000,(prgb[1]&0x3F)|bankmode);
setprg8(0xc000,(prgb[2]&0x3F)|bankmode);
setprg8(0xe000,0x3F|bankmode);
break;
case 04: if(tkcom[0]&0x80)
setprg8(0x6000,(((prgb[3]<<2)+3)&0x3F)|bankmode);
setprg32(0x8000,(prgb[3]&0x0F)|((tkcom[3]&6)<<3));
break;
case 05: if(tkcom[0]&0x80)
setprg8(0x6000,(((prgb[3]<<1)+1)&0x3F)|bankmode);
setprg16(0x8000,(prgb[1]&0x1F)|((tkcom[3]&6)<<4));
setprg16(0xC000,(prgb[3]&0x1F)|((tkcom[3]&6)<<4));
break;
case 07: // bit reversion
case 06: if(tkcom[0]&0x80)
setprg8(0x6000,(prgb[3]&0x3F)|bankmode);
setprg8(0x8000,(prgb[0]&0x3F)|bankmode);
setprg8(0xa000,(prgb[1]&0x3F)|bankmode);
setprg8(0xc000,(prgb[2]&0x3F)|bankmode);
setprg8(0xe000,(prgb[3]&0x3F)|bankmode);
break;
}
}
static void tekvrom(void)
{
int x, bank=0, mask=0xFFFF;
if(!(tkcom[3]&0x20))
{
bank=(tkcom[3]&1)|((tkcom[3]&0x18)>>2);
switch (tkcom[0]&0x18)
{
case 0x00: bank<<=5; mask=0x1F; break;
case 0x08: bank<<=6; mask=0x3F; break;
case 0x10: bank<<=7; mask=0x7F; break;
case 0x18: bank<<=8; mask=0xFF; break;
}
}
switch(tkcom[0]&0x18)
{
case 0x00: // 8KB
setchr8(((chrlow[0]|(chrhigh[0]<<8))&mask)|bank);
break;
case 0x08: // 4KB
for(x=0;x<8;x+=4)
setchr4(x<<10,((chrlow[x]|(chrhigh[x]<<8))&mask)|bank);
break;
case 0x10: // 2KB
for(x=0;x<8;x+=2)
setchr2(x<<10,((chrlow[x]|(chrhigh[x]<<8))&mask)|bank);
break;
case 0x18: // 1KB
for(x=0;x<8;x++)
setchr1(x<<10,((chrlow[x]|(chrhigh[x]<<8))&mask)|bank);
break;
}
}
static DECLFW(M90TekWrite)
{
switch(A)
{
case 0x5800: mul[0]=V; break;
case 0x5801: mul[1]=V; break;
case 0x5803: regie=V; break;
}
}
static DECLFR(M90TekRead)
{
switch(A)
{
case 0x5800: return (mul[0]*mul[1]);
case 0x5801: return((mul[0]*mul[1])>>8);
case 0x5803: return (regie);
}
return(tekker);
}
static DECLFW(M90PRGWrite)
{
prgb[A&3]=V;
tekprom();
}
static DECLFW(M90CHRlowWrite)
{
chrlow[A&7]=V;
tekvrom();
}
static DECLFW(M90CHRhiWrite)
{
chrhigh[A&7]=V;
tekvrom();
}
static DECLFW(M90NTWrite)
{
if(A&4)
{
names[A&3]&=0x00FF;
names[A&3]|=V<<8;
}
else
{
names[A&3]&=0xFF00;
names[A&3]|=V;
}
mira();
}
static DECLFW(M90IRQWrite)
{
switch(A&7)
{
case 00: //FCEU_printf("%s IRQ (C000)\n",V&1?"Enable":"Disable");
IRQa=V&1;if(!(V&1)) X6502_IRQEnd(FCEU_IQEXT);break;
case 02: //FCEU_printf("Disable IRQ (C002) scanline=%d\n", scanline);
IRQa=0;X6502_IRQEnd(FCEU_IQEXT);break;
case 03: //FCEU_printf("Enable IRQ (C003) scanline=%d\n", scanline);
IRQa=1;break;
case 01: IRQMode=V;
/* FCEU_printf("IRQ Count method: ");
switch (IRQMode&3)
{
case 00: FCEU_printf("M2 cycles\n");break;
case 01: FCEU_printf("PPU A12 toggles\n");break;
case 02: FCEU_printf("PPU reads\n");break;
case 03: FCEU_printf("Writes to CPU space\n");break;
}
FCEU_printf("Counter prescaler size: %s\n",(IRQMode&4)?"3 bits":"8 bits");
FCEU_printf("Counter prescaler size adjust: %s\n",(IRQMode&8)?"Used C007":"Normal Operation");
if((IRQMode>>6)==2) FCEU_printf("Counter Down\n");
else if((IRQMode>>6)==1) FCEU_printf("Counter Up\n");
else FCEU_printf("Counter Stopped\n");
*/ break;
case 04: //FCEU_printf("Pre Counter Loaded and Xored wiht C006: %d\n",V^IRQXOR);
IRQPre=V^IRQXOR;break;
case 05: //FCEU_printf("Main Counter Loaded and Xored wiht C006: %d\n",V^IRQXOR);
IRQCount=V^IRQXOR;break;
case 06: //FCEU_printf("Xor Value: %d\n",V);
IRQXOR=V;break;
case 07: //if(!(IRQMode&8)) FCEU_printf("C001 is clear, no effect applied\n");
// else if(V==0xFF) FCEU_printf("Prescaler is changed for 12bits\n");
// else FCEU_printf("Counter Stopped\n");
IRQPreSize=V;break;
}
}
static DECLFW(M90ModeWrite)
{
tkcom[A&3]=V;
tekprom();
tekvrom();
mira();
#ifdef DEBUG90
switch (A&3)
{
case 00: FCEU_printf("Main Control Register:\n");
FCEU_printf(" PGR Banking mode: %d\n",V&7);
FCEU_printf(" CHR Banking mode: %d\n",(V>>3)&3);
FCEU_printf(" 6000-7FFF addresses mapping: %s\n",(V&0x80)?"Yes":"No");
FCEU_printf(" Nametable control: %s\n",(V&0x20)?"Enabled":"Disabled");
if(V&0x20)
FCEU_printf(" Nametable can be: %s\n",(V&0x40)?"ROM Only":"RAM or ROM");
break;
case 01: FCEU_printf("Mirroring mode: ");
switch (V&3)
{
case 0: FCEU_printf("Vertical\n");break;
case 1: FCEU_printf("Horizontal\n");break;
case 2: FCEU_printf("Nametable 0 only\n");break;
case 3: FCEU_printf("Nametable 1 only\n");break;
}
FCEU_printf("Mirroring flag: %s\n",(V&0x80)?"On":"Off");
break;
case 02: if((((tkcom[0])>>5)&3)==1)
FCEU_printf("Nametable ROM/RAM select mode: %d\n",V>>7);
break;
case 03:
FCEU_printf("CHR Banking mode: %s\n",(V&0x20)?"Entire CHR ROM":"256Kb Switching mode");
if(!(V&0x20)) FCEU_printf("256K CHR bank number: %02x\n",(V&1)|((V&0x18)>>2));
FCEU_printf("512K PRG bank number: %d\n",(V&6)>>1);
FCEU_printf("CHR Bank mirroring: %s\n",(V&0x80)?"Swapped":"Normal operate");
}
#endif
}
static void CCL(void)
{
if((IRQMode>>6) == 1) // Count Up
{
IRQCount++;
if((IRQCount == 0) && IRQa)
{
X6502_IRQBegin(FCEU_IQEXT);
}
}
else if((IRQMode>>6) == 2) // Count down
{
IRQCount--;
if((IRQCount == 0xFF) && IRQa)
{
X6502_IRQBegin(FCEU_IQEXT);
}
}
}
static void ClockCounter(void)
{
uint8 premask;
if(IRQMode & 0x4)
premask = 0x7;
else
premask = 0xFF;
if((IRQMode>>6) == 1) // Count up
{
IRQPre++;
if((IRQPre & premask) == 0) CCL();
}
else if((IRQMode>>6) == 2) // Count down
{
IRQPre--;
if((IRQPre & premask) == premask) CCL();
}
}
void FP_FASTAPASS(1) CPUWrap(int a)
{
int x;
if((IRQMode&3)==0) for(x=0;x<a;x++) ClockCounter();
}
static void SLWrap(void)
{
int x;
if((IRQMode&3)==1) for(x=0;x<8;x++) ClockCounter();
}
static uint32 lastread;
static void FP_FASTAPASS(1) M90PPU(uint32 A)
{
if((IRQMode&3)==2)
{
if(lastread!=A)
{
ClockCounter();
ClockCounter();
}
lastread=A;
}
// else
// {
// if((!lastread)&&(A&0x1000))
// ClockCounter();
// lastread=A&0x1000;
// }
}
static void togglie()
{
tekker>>=6;
if(tekker>3)
tekker=0;
else
tekker++;
tekker<<=6;
FCEU_printf("tekker=%04x\n",tekker);
memset(tkcom,0x00,sizeof(tkcom));
memset(prgb,0xff,sizeof(prgb));
tekprom();
tekvrom();
}
static void M90Restore(int version)
{
tekprom();
tekvrom();
mira();
}
static void M90Power(void)
{
SetWriteHandler(0x5000,0x5fff,M90TekWrite);
SetWriteHandler(0x8000,0x8fff,M90PRGWrite);
SetWriteHandler(0x9000,0x9fff,M90CHRlowWrite);
SetWriteHandler(0xA000,0xAfff,M90CHRhiWrite);
SetWriteHandler(0xB000,0xBfff,M90NTWrite);
SetWriteHandler(0xC000,0xCfff,M90IRQWrite);
SetWriteHandler(0xD000,0xDfff,M90ModeWrite);
SetReadHandler(0x5000,0x5fff,M90TekRead);
SetReadHandler(0x6000,0xffff,CartBR);
mul[0]=mul[1]=regie=0xFF;
memset(tkcom,0x00,sizeof(tkcom));
memset(prgb,0xff,sizeof(prgb));
memset(chrlow,0xff,sizeof(chrlow));
memset(chrhigh,0xff,sizeof(chrhigh));
memset(names,0x00,sizeof(names));
if(is211)
tekker=0xC0;
else
tekker=0x00;
tekprom();
tekvrom();
}
void Mapper90_Init(CartInfo *info)
{
is211=0;
is209=0;
info->Reset=togglie;
info->Power=M90Power;
PPU_hook=M90PPU;
GameHBIRQHook2=SLWrap;
MapIRQHook=CPUWrap;
GameStateRestore=M90Restore;
AddExState(Tek_StateRegs, ~0, 0, 0);
}
void Mapper209_Init(CartInfo *info)
{
is211=0;
is209=1;
info->Reset=togglie;
info->Power=M90Power;
GameHBIRQHook2=SLWrap;
GameStateRestore=M90Restore;
AddExState(Tek_StateRegs, ~0, 0, 0);
}
void Mapper211_Init(CartInfo *info)
{
is211=1;
info->Reset=togglie;
info->Power=M90Power;
GameHBIRQHook2=SLWrap;
GameStateRestore=M90Restore;
AddExState(Tek_StateRegs, ~0, 0, 0);
}

View File

@ -1,124 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static uint8 lastA;
static uint8 DRegs[8];
static uint8 cmd;
static uint8 MirCache[8];
static SFORMAT DB_StateRegs[]={
{DRegs, 8, "DREG"},
{&cmd, 1, "CMD"},
{&lastA, 1, "LAST"},
{0}
};
static void toot(void)
{
int x;
MirCache[0]=MirCache[1]=(DRegs[0]>>4)&1;
MirCache[2]=MirCache[3]=(DRegs[1]>>4)&1;
for(x=0;x<4;x++)
MirCache[4+x]=(DRegs[2+x]>>5)&1;
onemir(MirCache[lastA]);
}
static void Sync()
{
setchr2(0x0000,DRegs[0]&0x1F);
setchr2(0x0800,DRegs[1]&0x1F);
setchr1(0x1000,DRegs[2]&0x1F);
setchr1(0x1400,DRegs[3]&0x1F);
setchr1(0x1800,DRegs[4]&0x1F);
setchr1(0x1C00,DRegs[5]&0x1F);
setprg8(0x8000,DRegs[6]&0x1F);
setprg8(0xa000,DRegs[7]&0x1F);
toot();
}
static DECLFW(Mapper95_write)
{
switch(A&0xF001)
{
case 0x8000: cmd = V; break;
case 0x8001:
switch(cmd&0x07)
{
case 0: DRegs[0]=(V&0x3F)>>1; break;
case 1: DRegs[1]=(V&0x3F)>>1; break;
case 2: DRegs[2]=V&0x3F; break;
case 3: DRegs[3]=V&0x3F; break;
case 4: DRegs[4]=V&0x3F; break;
case 5: DRegs[5]=V&0x3F; break;
case 6: DRegs[6]=V&0x3F; break;
case 7: DRegs[7]=V&0x3F; break;
}
Sync();
}
}
static void FP_FASTAPASS(1) dragonbust_ppu(uint32 A)
{
static int last=-1;
static uint8 z;
if(A>=0x2000) return;
A>>=10;
lastA=A;
z=MirCache[A];
if(z!=last)
{
onemir(z);
last=z;
}
}
static void DBPower(void)
{
memset(DRegs,0x3F,8);
DRegs[0]=DRegs[1]=0x1F;
Sync();
setprg8(0xc000,0x3E);
setprg8(0xe000,0x3F);
SetReadHandler(0x8000,0xffff,CartBR);
SetWriteHandler(0x8000,0xffff,Mapper95_write);
}
static void StateRestore(int version)
{
Sync();
}
void Mapper95_Init(CartInfo *info)
{
info->Power=DBPower;
AddExState(DB_StateRegs, ~0, 0, 0);
PPU_hook=dragonbust_ppu;
GameStateRestore=StateRestore;
}

View File

@ -1 +0,0 @@
fceu_SOURCES += boards/112.c boards/117.c boards/164.c boards/183.c boards/185.c boards/186.c boards/187.c boards/189.c boards/208.c boards/222.c boards/235.c boards/57.c boards/8157.c boards/8237.c boards/88.c boards/90.c boards/95.c boards/bmc13in1jy110.c boards/bmc42in1r.c boards/bmc64in1nr.c boards/bmc70in1.c boards/bmcgk192.c boards/bonza.c boards/cc21.c boards/datalatch.c boards/deirom.c boards/dream.c boards/fk23c.c boards/h2288.c boards/karaoke.c boards/kof97.c boards/konami-qtai.c boards/malee.c boards/mmc1.c boards/mmc3.c boards/mmc5.c boards/n106.c boards/novel.c boards/sachen.c boards/sheroes.c boards/sl1632.c boards/sonic5.c boards/subor.c boards/super24.c boards/supervision.c boards/t-262.c boards/tengen.c boards/__dummy_mapper.c

View File

@ -1,96 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2006 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static uint8 reg[8];
/*
static uint8 *WRAM=NULL;
static uint32 WRAMSIZE;
static uint8 *CHRRAM=NULL;
static uint32 CHRRAMSIZE;
*/
static SFORMAT StateRegs[]=
{
{reg, 8, "REGS"},
{0}
};
static void Sync(void)
{
}
static DECLFW(MNNNWrite)
{
}
static void MNNNPower(void)
{
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x8000,0xFFFF,MNNNWrite);
}
static void MNNNReset(void)
{
}
/*
static void MNNNClose(void)
{
if(WRAM)
FCEU_gfree(WRAM);
if(CHRRAM)
FCEU_gfree(CHRRAM);
WRAM=CHRRAM=NULL;
}
*/
static void MNNNIRQHook(void)
{
X6502_IRQBegin(FCEU_IQEXT);
}
static void StateRestore(int version)
{
Sync();
}
void MapperNNN_Init(CartInfo *info)
{
info->Reset=MNNNReset;
info->Power=MNNNPower;
// info->Close=MNNNClose;
GameHBIRQHook=MNNNIRQHook;
GameStateRestore=StateRestore;
/*
CHRRAMSIZE=8192;
CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSIZE);
SetupCartPRGMapping(0x10,CHRRAM,CHRRAMSIZE,1);
AddExState(CHRRAM, CHRRAMSIZE, 0, "WRAM");
*/
/*
WRAMSIZE=8192;
WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);
SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);
AddExState(WRAM, WRAMSIZE, 0, "WRAM");
*/
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,103 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* BMC 42-in-1 reset switch
*/
#include "mapinc.h"
static uint8 bank_mode;
static uint8 bank_value;
static uint8 prgb[4];
static SFORMAT StateRegs[]=
{
{0}
};
static void Sync(void)
{
FCEU_printf("%02x: %02x %02x\n", bank_mode, bank_value, prgb[0]);
switch(bank_mode&7)
{
case 0:
setprg32(0x8000,bank_value&7); break;
case 1:
setprg16(0x8000,((8+(bank_value&7))>>1)+prgb[1]);
setprg16(0xC000,(bank_value&7)>>1);
case 4:
setprg32(0x8000,8+(bank_value&7)); break;
case 5:
setprg16(0x8000,((8+(bank_value&7))>>1)+prgb[1]);
setprg16(0xC000,((8+(bank_value&7))>>1)+prgb[3]);
case 2:
setprg8(0x8000,prgb[0]>>2);
setprg8(0xa000,prgb[1]);
setprg8(0xc000,prgb[2]);
setprg8(0xe000,~0);
break;
case 3:
setprg8(0x8000,prgb[0]);
setprg8(0xa000,prgb[1]);
setprg8(0xc000,prgb[2]);
setprg8(0xe000,prgb[3]);
break;
}
}
static DECLFW(BMC13in1JY110Write)
{
FCEU_printf("%04x:%04x\n",A,V);
switch(A)
{
case 0x8000:
case 0x8001:
case 0x8002:
case 0x8003: prgb[A&3]=V; break;
case 0xD000: bank_mode=V; break;
case 0xD001: setmirror(V&3);
case 0xD002: break;
case 0xD003: bank_value=V; break;
}
Sync();
}
static void BMC13in1JY110Power(void)
{
prgb[0]=prgb[1]=prgb[2]=prgb[3]=0;
bank_mode=0;
bank_value=0;
setprg32(0x8000,0);
setchr8(0);
SetWriteHandler(0x8000,0xFFFF,BMC13in1JY110Write);
SetReadHandler(0x8000,0xFFFF,CartBR);
}
static void StateRestore(int version)
{
Sync();
}
void BMC13in1JY110_Init(CartInfo *info)
{
info->Power=BMC13in1JY110Power;
AddExState(&StateRegs, ~0, 0, 0);
GameStateRestore=StateRestore;
}

View File

@ -1,87 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* BMC 42-in-1 reset switch
*/
#include "mapinc.h"
static uint8 hrd_sw;
static uint8 latche;
static SFORMAT StateRegs[]=
{
{&latche, 1, "LATCHE"},
{&hrd_sw, 1, "HRDSW"},
{0}
};
static void Sync(void)
{
if(!(latche&0x20))
setprg32r(hrd_sw,0x8000,(latche>>1)&0x0f);
else
{
setprg16r(hrd_sw,0x8000,latche&0x1f);
setprg16r(hrd_sw,0xC000,latche&0x1f);
}
switch((latche>>6)&3)
{
case 0: setmirrorw(0,0,0,1); break;
case 1: setmirror(MI_V); break;
case 2: setmirror(MI_H); break;
case 3: setmirror(MI_1); break;
}
}
static DECLFW(BMC42in1rWrite)
{
latche=V;
Sync();
}
static void BMC42in1rReset(void)
{
hrd_sw^=1;
Sync();
}
static void BMC42in1rPower(void)
{
latche=0x00;
hrd_sw=0;
setchr8(0);
Sync();
SetWriteHandler(0x8000,0xFFFF,BMC42in1rWrite);
SetReadHandler(0x8000,0xFFFF,CartBR);
}
static void StateRestore(int version)
{
Sync();
}
void BMC42in1r_Init(CartInfo *info)
{
info->Power=BMC42in1rPower;
info->Reset=BMC42in1rReset;
AddExState(&StateRegs, ~0, 0, 0);
GameStateRestore=StateRestore;
}

View File

@ -1,93 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* BMC 42-in-1 reset switch
*/
#include "mapinc.h"
static uint8 regs[4];
static SFORMAT StateRegs[]=
{
{regs, 4, "REGS"},
{0}
};
static void Sync(void)
{
if(regs[0]&0x80)
{
if(regs[1]&0x80)
setprg32(0x8000,regs[1]&0x1F);
else
{
int bank=((regs[1]&0x1f)<<1)|((regs[1]>>6)&1);
setprg16(0x8000,bank);
setprg16(0xC000,bank);
}
}
else
{
int bank=((regs[1]&0x1f)<<1)|((regs[1]>>6)&1);
setprg16(0xC000,bank);
}
if(regs[0]&0x20)
setmirror(MI_H);
else
setmirror(MI_V);
setchr8((regs[2]<<2)|((regs[0]>>1)&3));
}
static DECLFW(BMC64in1nrWriteLo)
{
regs[A&3]=V;
Sync();
}
static DECLFW(BMC64in1nrWriteHi)
{
regs[3]=V;
Sync();
}
static void BMC64in1nrPower(void)
{
regs[0]=0x80;
regs[1]=0x43;
regs[2]=regs[3]=0;
Sync();
SetWriteHandler(0x5000,0x5003,BMC64in1nrWriteLo);
SetWriteHandler(0x8000,0xFFFF,BMC64in1nrWriteHi);
SetReadHandler(0x8000,0xFFFF,CartBR);
}
static void StateRestore(int version)
{
Sync();
}
void BMC64in1nr_Init(CartInfo *info)
{
info->Power=BMC64in1nrPower;
AddExState(&StateRegs, ~0, 0, 0);
GameStateRestore=StateRestore;
}

View File

@ -1,116 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static uint8 is_large_banks;
static uint8 large_bank;
static uint8 prg_bank;
static uint8 chr_bank;
static uint8 bank_mode;
static uint8 mirroring;
static SFORMAT StateRegs[]=
{
{&large_bank, 1, "LB"},
{&prg_bank, 1, "PRG"},
{&chr_bank, 1, "CHR"},
{&bank_mode, 1, "BM"},
{&mirroring, 1, "MIRR"},
{0}
};
static void Sync(void)
{
switch (bank_mode)
{
case 0x00:
case 0x10: setprg16(0x8000,large_bank|prg_bank);
setprg16(0xC000,large_bank|7);
break;
case 0x20: setprg32(0x8000,(large_bank|prg_bank)>>1);
break;
case 0x30: setprg16(0x8000,large_bank|prg_bank);
setprg16(0xC000,large_bank|prg_bank);
break;
}
setmirror(mirroring);
if(!is_large_banks)
setchr8(chr_bank);
}
static DECLFR(BMC70in1Read)
{
if(bank_mode==0x10)
if(is_large_banks)
return CartBR((A&0xFFF0)|0x06);
else
return CartBR((A&0xFFF0)|0x0d);
else
return CartBR(A);
}
static DECLFW(BMC70in1Write)
{
if(A&0x4000)
{
bank_mode=A&0x30;
prg_bank=A&7;
}
else
{
mirroring=((A&0x20)>>5)^1;
if(is_large_banks)
large_bank=(A&3)<<3;
else
chr_bank=A&7;
}
Sync();
}
static void BMC70in1Power(void)
{
setchr8(0);
bank_mode=0;
large_bank=0;
Sync();
SetReadHandler(0x8000,0xFFFF,BMC70in1Read);
SetWriteHandler(0x8000,0xffff,BMC70in1Write);
}
static void StateRestore(int version)
{
Sync();
}
void BMC70in1_Init(CartInfo *info)
{
is_large_banks=0;
info->Power=BMC70in1Power;
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}
void BMC70in1B_Init(CartInfo *info)
{
is_large_banks=1;
info->Power=BMC70in1Power;
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,67 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static uint16 addrlatche;
static void Sync(void)
{
if(addrlatche&0x40)
{
setprg16(0x8000,addrlatche&7);
setprg16(0xC000,addrlatche&7);
}
else
setprg32(0x8000,(addrlatche>>1)&3);
setchr8((addrlatche>>3)&7);
setmirror(((addrlatche&0x80)>>7)^1);
}
static DECLFW(BMCGK192Write)
{
addrlatche=A;
Sync();
}
static void BMCGK192Reset(void)
{
setprg32(0x8000,0);
}
static void BMCGK192Power(void)
{
setprg32(0x8000,0);
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x8000,0xffff,BMCGK192Write);
}
static void StateRestore(int version)
{
Sync();
}
void Mapper58_Init(CartInfo *info)
{
info->Power=BMCGK192Power;
info->Reset=BMCGK192Reset;
GameStateRestore=StateRestore;
AddExState(&addrlatche, 2, 0, "ALATC");
}

View File

@ -1,139 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static uint8 prg_reg;
static uint8 chr_reg;
static uint8 sim0reg, sim0bit, sim0byte, sim0parity, sim0bcnt;
static uint16 sim0data;
static uint8 sim0array[128] =
{
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0xAA,
};
static SFORMAT StateRegs[]=
{
{&prg_reg, 1, "PREG"},
{&chr_reg, 1, "CREG"},
{0}
};
static void Sync(void)
{
setprg32(0x8000, prg_reg);
setchr8(chr_reg);
}
static void StateRestore(int version)
{
Sync();
}
static DECLFW(M216WriteHi)
{
// FCEU_printf("%04x:%04x\n",A,V);
prg_reg=A&1;
chr_reg=(A&0x0E)>>1;
Sync();
}
static DECLFW(M216Write5000)
{
// FCEU_printf("WRITE: %04x:%04x\n",A,V);
sim0reg=V;
if(!sim0reg)
{
sim0bit=sim0byte=sim0parity=0;
sim0data=sim0array[0];
sim0bcnt=0x80;
}
else if(sim0reg&0x20)
{
sim0bcnt=0x20;
}
}
static DECLFR(M216Read5000)
{
if(sim0reg&0x60)
{
sim0reg=(sim0reg^(sim0reg<<1))&0x40;
return sim0reg;
}
else
{
uint8 sim0out=0;
if(sim0bit<8)
{
// sim0data=((sim0array[sim0byte]<<(sim0bit))&0x80)>>1;
sim0out=(sim0data&1)<<6;
sim0data>>=1;
sim0bit++;
sim0parity+=sim0data;
}
else if(sim0bit==8)
{
sim0bit++;
sim0out=sim0parity&1;
}
else if(sim0bit==9)
{
if(sim0byte==sim0bcnt)
sim0out=0x60;
else
{
sim0bit=0;
sim0byte++;
sim0data=sim0array[sim0byte];
sim0out=0;
}
}
// FCEU_printf("READ: %04x (%04x-%02x,%04x)\n",A,X.PC,sim0out,sim0byte);
return sim0out;
}
}
static void Power(void)
{
prg_reg = 0;
chr_reg = 0;
Sync();
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x8000,0xFFFF,M216WriteHi);
SetWriteHandler(0x5000,0x5000,M216Write5000);
SetReadHandler(0x5000,0x5000,M216Read5000);
}
void Mapper216_Init(CartInfo *info)
{
info->Power=Power;
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,56 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static uint16 addrlatche;
//------------------ UNLCC21 ---------------------------
static void UNLCC21Sync(void)
{
setchr8(addrlatche&1);
setmirror(MI_0+((addrlatche&2)>>1));
}
static DECLFW(UNLCC21Write)
{
addrlatche=A;
UNLCC21Sync();
}
static void UNLCC21Power(void)
{
setprg32(0x8000,0);
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x8000,0xffff,UNLCC21Write);
}
static void UNLCC21Restore(int version)
{
UNLCC21Sync();
}
void UNLCC21_Init(CartInfo *info)
{
info->Power=UNLCC21Power;
GameStateRestore=UNLCC21Restore;
AddExState(&addrlatche, 2, 0, "ALATC");
}

View File

@ -1,272 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static uint8 latche, latcheinit;
static uint16 addrreg0, addrreg1;
static void(*WSync)(void);
static DECLFW(LatchWrite)
{
latche=V;
WSync();
}
static void LatchPower(void)
{
latche=latcheinit;
WSync();
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(addrreg0,addrreg1,LatchWrite);
}
static void StateRestore(int version)
{
WSync();
}
void Latch_Init(CartInfo *info, void (*proc)(void), uint8 init, uint16 adr0, uint16 adr1)
{
latcheinit=init;
addrreg0=adr0;
addrreg1=adr1;
WSync=proc;
info->Power=LatchPower;
GameStateRestore=StateRestore;
AddExState(&latche, 1, 0, "LATC");
}
//------------------ CPROM ---------------------------
static void CPROMSync(void)
{
setchr4(0x0000,0);
setchr4(0x1000,latche&3);
setprg16(0x8000,0);
setprg16(0xC000,1);
}
void CPROM_Init(CartInfo *info)
{
Latch_Init(info, CPROMSync, 0, 0x8000, 0xFFFF);
}
//------------------ CNROM ---------------------------
static void CNROMSync(void)
{
setchr8(latche&3);
setprg16(0x8000,0);
setprg16(0xC000,1);
}
void CNROM_Init(CartInfo *info)
{
Latch_Init(info, CNROMSync, 0, 0x8000, 0xFFFF);
}
//------------------ ANROM ---------------------------
static void ANROMSync()
{
setprg32(0x8000,latche&0xf);
setmirror(MI_0+((latche>>4)&1));
setchr8(0);
}
void ANROM_Init(CartInfo *info)
{
Latch_Init(info, ANROMSync, 0, 0x8000, 0xFFFF);
}
//------------------ Map 70 ---------------------------
static void M70Sync()
{
setprg16(0x8000,latche>>4);
setprg16(0xc000,~0);
setchr8(latche&0xf);
}
void Mapper70_Init(CartInfo *info)
{
Latch_Init(info, M70Sync, 0, 0x8000, 0xFFFF);
}
//------------------ Map 152 ---------------------------
static void M152Sync()
{
setprg16(0x8000,(latche>>4)&7);
setprg16(0xc000,~0);
setchr8(latche&0xf);
setmirror(MI_0+((latche>>7)&1)); /* Saint Seiya...hmm. */
}
void Mapper152_Init(CartInfo *info)
{
Latch_Init(info, M152Sync, 0, 0x8000, 0xFFFF);
}
//------------------ Map 78 ---------------------------
/* Should be two separate emulation functions for this "mapper". Sigh. URGE TO KILL RISING. */
static void M78Sync()
{
setprg16(0x8000,(latche&7));
setprg16(0xc000,~0);
setchr8(latche>>4);
setmirror(MI_0+((latche>>3)&1));
}
void Mapper78_Init(CartInfo *info)
{
Latch_Init(info, M78Sync, 0, 0x8000, 0xFFFF);
}
//------------------ MHROM ---------------------------
static void MHROMSync(void)
{
setprg32(0x8000,latche>>4);
setchr8(latche&0xf);
}
void MHROM_Init(CartInfo *info)
{
Latch_Init(info, MHROMSync, 0, 0x8000, 0xFFFF);
}
void Mapper140_Init(CartInfo *info)
{
Latch_Init(info, MHROMSync, 0, 0x6000, 0x7FFF);
}
//------------------ Map 87 ---------------------------
static void M87Sync(void)
{
setprg16(0x8000,0);
setprg16(0xC000,1);
setchr8(latche>>1);
}
void Mapper87_Init(CartInfo *info)
{
Latch_Init(info, M87Sync, ~0, 0x6000, 0xFFFF);
}
//------------------ Map 11 ---------------------------
static void M11Sync(void)
{
setprg32(0x8000,latche&0xf);
setchr8(latche>>4);
}
void Mapper11_Init(CartInfo *info)
{
Latch_Init(info, M11Sync, 0, 0x8000, 0xFFFF);
}
void Mapper144_Init(CartInfo *info)
{
Latch_Init(info, M11Sync, 0, 0x8001, 0xFFFF);
}
//------------------ UNROM ---------------------------
static void UNROMSync(void)
{
setprg16(0x8000,latche);
setprg16(0xc000,~0);
setchr8(0);
}
void UNROM_Init(CartInfo *info)
{
Latch_Init(info, UNROMSync, 0, 0x8000, 0xFFFF);
}
//------------------ Map 93 ---------------------------
static void SSUNROMSync(void)
{
setprg16(0x8000,latche>>4);
setprg16(0xc000,~0);
setchr8(0);
}
void SUNSOFT_UNROM_Init(CartInfo *info)
{
Latch_Init(info, SSUNROMSync, 0, 0x8000, 0xFFFF);
}
//------------------ Map 94 ---------------------------
static void M94Sync(void)
{
setprg16(0x8000,latche>>2);
setprg16(0xc000,~0);
setchr8(0);
}
void Mapper94_Init(CartInfo *info)
{
Latch_Init(info, M94Sync, 0, 0x8000, 0xFFFF);
}
//------------------ Map 107 ---------------------------
static void M107Sync(void)
{
setprg32(0x8000,(latche>>1)&3);
setchr8(latche&7);
}
void Mapper107_Init(CartInfo *info)
{
Latch_Init(info, M107Sync, ~0, 0x8000, 0xFFFF);
}
//------------------ NROM ---------------------------
#ifdef DEBUG_MAPPER
static DECLFW(WriteHandler)
{
FCEU_printf("$%04x:$%02x\n",A,V);
}
#endif
static void NROMPower(void)
{
setprg16(0x8000,0);
setprg16(0xC000,~0);
setchr8(0);
SetReadHandler(0x8000,0xFFFF,CartBR);
#ifdef DEBUG_MAPPER
SetWriteHandler(0x4020,0xFFFF,WriteHandler);
#endif
}
void NROM_Init(CartInfo *info)
{
info->Power=NROMPower;
}

View File

@ -1,82 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static uint8 cmd;
static uint8 DRegs[8];
static SFORMAT DEI_StateRegs[]=
{
{&cmd, 1, "CMD"},
{DRegs, 8, "DREG"},
{0}
};
static void Sync(void)
{
setchr2(0x0000,DRegs[0]);
setchr2(0x0800,DRegs[1]);
int x;
for(x=0;x<4;x++)
setchr1(0x1000+(x<<10),DRegs[2+x]);
setprg8(0x8000,DRegs[6]);
setprg8(0xa000,DRegs[7]);
}
static void StateRestore(int version)
{
Sync();
}
static DECLFW(DEIWrite)
{
switch(A&0x8001)
{
case 0x8000: cmd=V&0x07; break;
case 0x8001: if(cmd<=0x05)
V&=0x3F;
else
V&=0x0F;
if(cmd<=0x01) V>>=1;
DRegs[cmd&0x07]=V;
Sync();
break;
}
}
static void DEIPower(void)
{
setprg8(0xc000,0xE);
setprg8(0xe000,0xF);
cmd=0;
memset(DRegs,0,8);
Sync();
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x8000,0xFFFF,DEIWrite);
}
void DEIROM_Init(CartInfo *info)
{
info->Power=DEIPower;
GameStateRestore=StateRestore;
AddExState(&DEI_StateRegs, ~0, 0, 0);
}

View File

@ -1,56 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static uint8 latche;
static void Sync(void)
{
setprg16(0x8000,latche);
setprg16(0xC000,8);
}
static DECLFW(DREAMWrite)
{
latche=V&7;
Sync();
}
static void DREAMPower(void)
{
latche=0;
Sync();
setchr8(0);
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x5020,0x5020,DREAMWrite);
}
static void Restore(int version)
{
Sync();
}
void DreamTech01_Init(CartInfo *info)
{
GameStateRestore=Restore;
info->Power=DREAMPower;
AddExState(&latche, 1, 0, "LATCH");
}

View File

@ -1,112 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
#include "mmc3.h"
static uint8 unromchr;
static void BMCFK23CCW(uint32 A, uint8 V)
{
if(EXPREGS[0]&0x40)
setchr8((EXPREGS[2]&0xFC)|unromchr);
else
{
uint16 base=(EXPREGS[2]&0x7F)<<3;
setchr1(A,V|base);
if(EXPREGS[3]&2)
{
setchr1(0x0400,EXPREGS[6]|base);
setchr1(0x0C00,EXPREGS[7]|base);
}
}
}
static void BMCFK23CPW(uint32 A, uint8 V)
{
if(EXPREGS[0]&4)
setprg32(0x8000,EXPREGS[1]>>1);
else
{
if(EXPREGS[0]&2)
setprg8(A,(V&(0x3F>>(EXPREGS[0]&3)))|(EXPREGS[1]<<1));
else
setprg8(A,V);
if(EXPREGS[3]&2)
{
setprg8(0xC000,EXPREGS[4]);
setprg8(0xE000,EXPREGS[5]);
}
}
}
static DECLFW(BMCFK23C8003Write)
{
if(EXPREGS[0]&0x40)
{
unromchr=V&3;
FixMMC3CHR(MMC3_cmd);
}
else
{
if((A==0x8001)&&(EXPREGS[3]&2&&MMC3_cmd&8))
{
EXPREGS[4|(MMC3_cmd&3)]=V;
FixMMC3PRG(MMC3_cmd);
FixMMC3CHR(MMC3_cmd);
}
else
MMC3_CMDWrite(A,V);
}
}
static DECLFW(BMCFK23CWrite)
{
EXPREGS[A&3]=V;
FixMMC3PRG(MMC3_cmd);
FixMMC3CHR(MMC3_cmd);
}
static void BMCFK23CReset(void)
{
EXPREGS[0]=EXPREGS[1]=EXPREGS[2]=EXPREGS[3]=0;
EXPREGS[4]=EXPREGS[5]=EXPREGS[6]=EXPREGS[7]=0xFF;
MMC3RegReset();
}
static void BMCFK23CPower(void)
{
EXPREGS[0]=EXPREGS[1]=EXPREGS[2]=EXPREGS[3]=0;
EXPREGS[4]=EXPREGS[5]=EXPREGS[6]=EXPREGS[7]=0xFF;
GenMMC3Power();
SetWriteHandler(0x5ff0,0x5fff,BMCFK23CWrite);
SetWriteHandler(0x8000,0x8003,BMCFK23C8003Write);
}
void BMCFK23C_Init(CartInfo *info)
{
GenMMC3_Init(info, 512, 256, 8, 0);
cwrap=BMCFK23CCW;
pwrap=BMCFK23CPW;
info->Power=BMCFK23CPower;
info->Reset=BMCFK23CReset;
AddExState(EXPREGS, 8, 0, "EXPR");
AddExState(&unromchr, 1, 0, "UNCHR");
}

View File

@ -1,89 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
#include "mmc3.h"
extern uint8 m114_perm[8];
static void H2288PW(uint32 A, uint8 V)
{
if(EXPREGS[0]&0x40)
{
uint8 bank=(EXPREGS[0]&5)|((EXPREGS[0]&8)>>2)|((EXPREGS[0]&0x20)>>2);
if(EXPREGS[0]&2)
setprg32(0x8000,bank>>1);
else
{
setprg16(0x8000,bank);
setprg16(0xC000,bank);
}
}
else
setprg8(A,V&0x3F);
}
static DECLFW(H2288WriteHi)
{
switch (A&0x8001)
{
case 0x8000: MMC3_CMDWrite(0x8000,(V&0xC0)|(m114_perm[V&7])); break;
case 0x8001: MMC3_CMDWrite(0x8001,V); break;
}
}
static DECLFW(H2288WriteLo)
{
if(A&0x800)
{
if(A&1)
EXPREGS[1]=V;
else
EXPREGS[0]=V;
FixMMC3PRG(MMC3_cmd);
}
}
static DECLFR(H2288Read)
{
int bit;
bit=(A&1)^1;
bit&=((A>>8)&1);
bit^=1;
return((X.DB&0xFE)|bit);
}
static void H2288Power(void)
{
EXPREGS[0]=EXPREGS[1]=0;
GenMMC3Power();
SetReadHandler(0x5000,0x5FFF,H2288Read);
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x5000,0x5FFF,H2288WriteLo);
SetWriteHandler(0x8000,0x8FFF,H2288WriteHi);
}
void UNLH2288_Init(CartInfo *info)
{
GenMMC3_Init(info, 256, 256, 0, 0);
pwrap=H2288PW;
info->Power=H2288Power;
AddExState(EXPREGS, 2, 0, "EXPR");
}

View File

@ -1,71 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
extern uint32 ROM_size;
static uint8 latche;
static void Sync(void)
{
if(latche)
{
if(latche&0x10)
setprg16(0x8000,(latche&7));
else
setprg16(0x8000,(latche&7)|8);
}
else
setprg16(0x8000,7+(ROM_size>>4));
}
static DECLFW(M188Write)
{
latche=V;
Sync();
}
static DECLFR(ExtDev)
{
return(3);
}
static void Power(void)
{
latche=0;
Sync();
setchr8(0);
setprg16(0xc000,0x7);
SetReadHandler(0x6000,0x7FFF,ExtDev);
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x8000,0xFFFF,M188Write);
}
static void StateRestore(int version)
{
Sync();
}
void Mapper188_Init(CartInfo *info)
{
info->Power=Power;
GameStateRestore=StateRestore;
AddExState(&latche, 1, 0, "LATCH");
}

View File

@ -1,50 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
#include "mmc3.h"
static DECLFW(UNLKOF97CMDWrite)
{
V=(V&0xD8)|((V&0x20)>>4)|((V&4)<<3)|((V&2)>>1)|((V&1)<<2); //76143502
if(A==0x9000) A=0x8001;
MMC3_CMDWrite(A,V);
}
static DECLFW(UNLKOF97IRQWrite)
{
V=(V&0xD8)|((V&0x20)>>4)|((V&4)<<3)|((V&2)>>1)|((V&1)<<2);
if(A==0xD000) A=0xC001;
else if(A==0xF000) A=0xE001;
MMC3_IRQWrite(A,V);
}
static void UNLKOF97Power(void)
{
GenMMC3Power();
SetWriteHandler(0x8000,0xA000,UNLKOF97CMDWrite);
SetWriteHandler(0xC000,0xF000,UNLKOF97IRQWrite);
}
void UNLKOF97_Init(CartInfo *info)
{
GenMMC3_Init(info, 128, 256, 0, 0);
info->Power=UNLKOF97Power;
}

View File

@ -1,128 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* CAI Shogakko no Sansu
*/
#include "mapinc.h"
static uint8 *CHRRAM=NULL;
static uint8 SWRAM[4096];
static uint8 regs[16];
static uint8 WRAM[4096];
static SFORMAT StateRegs[]=
{
{&regs, 16, "REGS"},
{WRAM, 4096, "WRAM"},
{0}
};
static void Sync(void)
{
if(regs[5]&0x40)
{
setchr4r(0,0x1000,regs[5]&0x3F);
}
else
{
setchr4r(0x10,0x0000,regs[5]);
setchr4r(0x10,0x1000,regs[5]^1);
}
setprg8r((regs[2]>>6)&1,0x8000,(regs[2]&0x3F));
setprg8r((regs[3]>>6)&1,0xA000,(regs[3]&0x3F));
setprg8r((regs[4]>>6)&1,0xC000,(regs[4]&0x3F));
setprg8r(1,0xE000,~0);
setmirror((regs[0xA]&3));
}
static DECLFW(M190Write)
{
// FCEU_printf("write %04x:%04x %d, %d\n",A,V,scanline,timestamp);
regs[(A&0x0F00)>>8]=V;
Sync();
}
static DECLFR(M190Read)
{
// FCEU_printf("read %04x:%04x %d, %d\n",A,regs[(A&0x0F00)>>8],scanline,timestamp);
return regs[(A&0x0F00)>>8];
}
static DECLFR(AWRAM)
{
return(WRAM[A-0x7000]);
}
static DECLFW(BWRAM)
{
WRAM[A-0x7000]=V;
}
static DECLFR(ASWRAM)
{
return(SWRAM[A-0x6000]);
}
static DECLFW(BSWRAM)
{
SWRAM[A-0x6000]=V;
}
static void M190Power(void)
{
setvram8(CHRRAM);
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x8000,0xFFFF,M190Write);
// SetReadHandler(0xDA00,0xDA00,M190Read);
// SetReadHandler(0xDB00,0xDB00,M190Read);
SetReadHandler(0xDC00,0xDC00,M190Read);
SetReadHandler(0xDD00,0xDD00,M190Read);
SetReadHandler(0x7000,0x7FFF,AWRAM);
SetWriteHandler(0x7000,0x7FFF,BWRAM);
SetReadHandler(0x6000,0x6FFF,ASWRAM);
SetWriteHandler(0x6000,0x6FFF,BSWRAM);
Sync();
}
static void M190Close(void)
{
if(CHRRAM)
FCEU_gfree(CHRRAM);
CHRRAM=NULL;
}
static void StateRestore(int version)
{
Sync();
}
void Mapper190_Init(CartInfo *info)
{
info->Power=M190Power;
info->Close=M190Close;
if(info->battery)
{
info->SaveGame[0]=SWRAM;
info->SaveGameLen[0]=4096;
}
GameStateRestore=StateRestore;
CHRRAM=(uint8*)FCEU_gmalloc(8192);
SetupCartCHRMapping(0x10,CHRRAM,8192,1);
AddExState(CHRRAM, 8192, 0, "CHRRAM");
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,41 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static uint8 WRAM[2048];
static void MALEEReset(void)
{
setprg2r(0x10,0x7000,0);
SetReadHandler(0x8000,0xFFFF,CartBR);
SetReadHandler(0x6000,0x67FF,CartBR);
SetReadHandler(0x7000,0x77FF,CartBR);
setprg2r(1,0x6000,0);
setprg32(0x8000,0);
setchr8(0);
}
void MALEE_Init(CartInfo *info)
{
info->Power=MALEEReset;
SetupCartPRGMapping(0x10, WRAM, 2048, 1);
AddExState(WRAM, 2048, 0,"RAM");
}

View File

@ -1,11 +0,0 @@
#include "../types.h"
#include "../x6502.h"
#include "../fceu.h"
#include "../ppu.h"
#include "../memory.h"
#include "../sound.h"
#include "../state.h"
#include "../cart.h"
#include "../cheat.h"
#include "../unif.h"
#include <string.h>

View File

@ -1,423 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 1998 BERO
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static void GenMMC1Power(void);
static void GenMMC1Init(CartInfo *info, int prg, int chr, int wram, int battery);
static uint8 DRegs[4];
static uint8 Buffer,BufferShift;
static int mmc1opts;
static void (*MMC1CHRHook4)(uint32 A, uint8 V);
static void (*MMC1PRGHook16)(uint32 A, uint8 V);
static uint8 *WRAM=NULL;
static uint8 *CHRRAM=NULL;
static int is155;
static DECLFW(MBWRAM)
{
if(!(DRegs[3]&0x10)||is155)
Page[A>>11][A]=V; // WRAM is enabled.
}
static DECLFR(MAWRAM)
{
if((DRegs[3]&0x10)&&!is155)
return X.DB; // WRAM is disabled
return(Page[A>>11][A]);
}
static void MMC1CHR(void)
{
if(mmc1opts&4)
{
if(DRegs[0]&0x10)
setprg8r(0x10,0x6000,(DRegs[1]>>4)&1);
else
setprg8r(0x10,0x6000,(DRegs[1]>>3)&1);
}
if(MMC1CHRHook4)
{
if(DRegs[0]&0x10)
{
MMC1CHRHook4(0x0000,DRegs[1]);
MMC1CHRHook4(0x1000,DRegs[2]);
}
else
{
MMC1CHRHook4(0x0000,(DRegs[1]&0xFE));
MMC1CHRHook4(0x1000,DRegs[1]|1);
}
}
else
{
if(DRegs[0]&0x10)
{
setchr4(0x0000,DRegs[1]);
setchr4(0x1000,DRegs[2]);
}
else
setchr8(DRegs[1]>>1);
}
}
static void MMC1PRG(void)
{
uint8 offs=DRegs[1]&0x10;
if(MMC1PRGHook16)
{
switch(DRegs[0]&0xC)
{
case 0xC: MMC1PRGHook16(0x8000,(DRegs[3]+offs));
MMC1PRGHook16(0xC000,0xF+offs);
break;
case 0x8: MMC1PRGHook16(0xC000,(DRegs[3]+offs));
MMC1PRGHook16(0x8000,offs);
break;
case 0x0:
case 0x4:
MMC1PRGHook16(0x8000,((DRegs[3]&~1)+offs));
MMC1PRGHook16(0xc000,((DRegs[3]&~1)+offs+1));
break;
}
}
else switch(DRegs[0]&0xC)
{
case 0xC: setprg16(0x8000,(DRegs[3]+offs));
setprg16(0xC000,0xF+offs);
break;
case 0x8: setprg16(0xC000,(DRegs[3]+offs));
setprg16(0x8000,offs);
break;
case 0x0:
case 0x4:
setprg16(0x8000,((DRegs[3]&~1)+offs));
setprg16(0xc000,((DRegs[3]&~1)+offs+1));
break;
}
}
static void MMC1MIRROR(void)
{
switch(DRegs[0]&3)
{
case 2: setmirror(MI_V); break;
case 3: setmirror(MI_H); break;
case 0: setmirror(MI_0); break;
case 1: setmirror(MI_1); break;
}
}
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);
//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;
if(V&0x80)
{
DRegs[0]|=0xC;
BufferShift=Buffer=0;
MMC1PRG();
lreset=timestampbase+timestamp;
return;
}
Buffer|=(V&1)<<(BufferShift++);
if(BufferShift==5)
{
DRegs[n] = Buffer;
BufferShift = Buffer = 0;
switch(n)
{
case 0: MMC1MIRROR(); MMC1CHR(); MMC1PRG(); break;
case 1: MMC1CHR(); MMC1PRG(); break;
case 2: MMC1CHR(); break;
case 3: MMC1PRG(); break;
}
}
}
static void MMC1_Restore(int version)
{
MMC1MIRROR();
MMC1CHR();
MMC1PRG();
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;
MMC1MIRROR();
MMC1CHR();
MMC1PRG();
}
static int DetectMMC1WRAMSize(uint32 crc32)
{
switch(crc32)
{
case 0xc6182024: /* Romance of the 3 Kingdoms */
case 0x2225c20f: /* Genghis Khan */
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;
default:return(8);
}
}
static uint32 NWCIRQCount;
static uint8 NWCRec;
#define NWCDIP 0xE
static void FP_FASTAPASS(1) NWCIRQHook(int a)
{
if(!(NWCRec&0x10))
{
NWCIRQCount+=a;
if((NWCIRQCount|(NWCDIP<<25))>=0x3e000000)
{
NWCIRQCount=0;
X6502_IRQBegin(FCEU_IQEXT);
}
}
}
static void NWCCHRHook(uint32 A, uint8 V)
{
if((V&0x10)) // && !(NWCRec&0x10))
{
NWCIRQCount=0;
X6502_IRQEnd(FCEU_IQEXT);
}
NWCRec=V;
if(V&0x08)
MMC1PRG();
else
setprg32(0x8000,(V>>1)&3);
}
static void NWCPRGHook(uint32 A, uint8 V)
{
if(NWCRec&0x8)
setprg16(A,8|(V&0x7));
else
setprg32(0x8000,(NWCRec>>1)&3);
}
static void NWCPower(void)
{
GenMMC1Power();
setchr8r(0,0);
}
void Mapper105_Init(CartInfo *info)
{
GenMMC1Init(info, 256, 256, 8, 0);
MMC1CHRHook4=NWCCHRHook;
MMC1PRGHook16=NWCPRGHook;
MapIRQHook=NWCIRQHook;
info->Power=NWCPower;
}
static void GenMMC1Power(void)
{
lreset=0;
if(mmc1opts&1)
{
FCEU_CheatAddRAM(8,0x6000,WRAM);
if(mmc1opts&4)
FCEU_dwmemset(WRAM,0,8192)
else if(!(mmc1opts&2))
FCEU_dwmemset(WRAM,0,8192);
}
SetWriteHandler(0x8000,0xFFFF,MMC1_write);
SetReadHandler(0x8000,0xFFFF,CartBR);
if(mmc1opts&1)
{
SetReadHandler(0x6000,0x7FFF,MAWRAM);
SetWriteHandler(0x6000,0x7FFF,MBWRAM);
setprg8r(0x10,0x6000,0);
}
MMC1CMReset();
}
static void GenMMC1Close(void)
{
if(CHRRAM)
FCEU_gfree(CHRRAM);
if(WRAM)
FCEU_gfree(WRAM);
CHRRAM=WRAM=NULL;
}
static void GenMMC1Init(CartInfo *info, int prg, int chr, int wram, int battery)
{
is155=0;
info->Close=GenMMC1Close;
MMC1PRGHook16=MMC1CHRHook4=0;
mmc1opts=0;
PRGmask16[0]&=(prg>>14)-1;
CHRmask4[0]&=(chr>>12)-1;
CHRmask8[0]&=(chr>>13)-1;
if(wram)
{
WRAM=(uint8*)FCEU_gmalloc(wram*1024);
mmc1opts|=1;
if(wram>8) mmc1opts|=4;
SetupCartPRGMapping(0x10,WRAM,wram*1024,1);
AddExState(WRAM, wram*1024, 0, "WRAM");
if(battery)
{
mmc1opts|=2;
info->SaveGame[0]=WRAM+((mmc1opts&4)?8192:0);
info->SaveGameLen[0]=8192;
}
}
if(!chr)
{
CHRRAM=(uint8*)FCEU_gmalloc(8192);
SetupCartCHRMapping(0, CHRRAM, 8192, 1);
AddExState(CHRRAM, 8192, 0, "CHRR");
}
AddExState(DRegs, 4, 0, "DREG");
info->Power=GenMMC1Power;
GameStateRestore=MMC1_Restore;
AddExState(&lreset, 8, 1, "LRST");
}
void Mapper1_Init(CartInfo *info)
{
int ws=DetectMMC1WRAMSize(info->CRC32);
GenMMC1Init(info, 512, 256, ws, info->battery);
}
/* Same as mapper 1, without respect for WRAM enable bit. */
void Mapper155_Init(CartInfo *info)
{
GenMMC1Init(info,512,256,8,info->battery);
is155=1;
}
void SAROM_Init(CartInfo *info)
{
GenMMC1Init(info, 128, 64, 8, info->battery);
}
void SBROM_Init(CartInfo *info)
{
GenMMC1Init(info, 128, 64, 0, 0);
}
void SCROM_Init(CartInfo *info)
{
GenMMC1Init(info, 128, 128, 0, 0);
}
void SEROM_Init(CartInfo *info)
{
GenMMC1Init(info, 32, 64, 0, 0);
}
void SGROM_Init(CartInfo *info)
{
GenMMC1Init(info, 256, 0, 0, 0);
}
void SKROM_Init(CartInfo *info)
{
GenMMC1Init(info, 256, 64, 8, info->battery);
}
void SLROM_Init(CartInfo *info)
{
GenMMC1Init(info, 256, 128, 0, 0);
}
void SL1ROM_Init(CartInfo *info)
{
GenMMC1Init(info, 128, 128, 0, 0);
}
/* Begin unknown - may be wrong - perhaps they use different MMC1s from the
similarly functioning boards?
*/
void SL2ROM_Init(CartInfo *info)
{
GenMMC1Init(info, 256, 256, 0, 0);
}
void SFROM_Init(CartInfo *info)
{
GenMMC1Init(info, 256, 256, 0, 0);
}
void SHROM_Init(CartInfo *info)
{
GenMMC1Init(info, 256, 256, 0, 0);
}
/* End unknown */
/* */
/* */
void SNROM_Init(CartInfo *info)
{
GenMMC1Init(info, 256, 0, 8, info->battery);
}
void SOROM_Init(CartInfo *info)
{
GenMMC1Init(info, 256, 0, 16, info->battery);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,23 +0,0 @@
extern uint8 MMC3_cmd;
extern uint8 *WRAM;
extern uint8 *CHRRAM;
extern uint8 EXPREGS[8];
#undef IRQCount
#undef IRQLatch
#undef IRQa
extern uint8 IRQCount,IRQLatch,IRQa;
extern uint8 IRQReload;
extern void (*pwrap)(uint32 A, uint8 V);
extern void (*cwrap)(uint32 A, uint8 V);
extern void (*mwrap)(uint8 V);
void GenMMC3Power(void);
void GenMMC3Restore(int version);
void MMC3RegReset(void);
void FixMMC3PRG(int V);
void FixMMC3CHR(int V);
DECLFW(MMC3_CMDWrite);
DECLFW(MMC3_IRQWrite);
void GenMMC3_Init(CartInfo *info, int prg, int chr, int wram, int battery);

View File

@ -1,834 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* None of this code should use any of the iNES bank switching wrappers. */
#include "mapinc.h"
static void (*sfun)(int P);
static void (*psfun)(void);
void MMC5RunSound(int Count);
void MMC5RunSoundHQ(void);
static INLINE void MMC5SPRVROM_BANK1(uint32 A,uint32 V)
{
if(CHRptr[0])
{
V&=CHRmask1[0];
MMC5SPRVPage[(A)>>10]=&CHRptr[0][(V)<<10]-(A);
}
}
static INLINE void MMC5BGVROM_BANK1(uint32 A,uint32 V) {if(CHRptr[0]){V&=CHRmask1[0];MMC5BGVPage[(A)>>10]=&CHRptr[0][(V)<<10]-(A);}}
static INLINE void MMC5SPRVROM_BANK2(uint32 A,uint32 V) {if(CHRptr[0]){V&=CHRmask2[0];MMC5SPRVPage[(A)>>10]=MMC5SPRVPage[((A)>>10)+1]=&CHRptr[0][(V)<<11]-(A);}}
static INLINE void MMC5BGVROM_BANK2(uint32 A,uint32 V) {if(CHRptr[0]){V&=CHRmask2[0];MMC5BGVPage[(A)>>10]=MMC5BGVPage[((A)>>10)+1]=&CHRptr[0][(V)<<11]-(A);}}
static INLINE void MMC5SPRVROM_BANK4(uint32 A,uint32 V) {if(CHRptr[0]){V&=CHRmask4[0];MMC5SPRVPage[(A)>>10]=MMC5SPRVPage[((A)>>10)+1]= MMC5SPRVPage[((A)>>10)+2]=MMC5SPRVPage[((A)>>10)+3]=&CHRptr[0][(V)<<12]-(A);}}
static INLINE void MMC5BGVROM_BANK4(uint32 A,uint32 V) {if(CHRptr[0]){V&=CHRmask4[0];MMC5BGVPage[(A)>>10]=MMC5BGVPage[((A)>>10)+1]=MMC5BGVPage[((A)>>10)+2]=MMC5BGVPage[((A)>>10)+3]=&CHRptr[0][(V)<<12]-(A);}}
static INLINE void MMC5SPRVROM_BANK8(uint32 V) {if(CHRptr[0]){V&=CHRmask8[0];MMC5SPRVPage[0]=MMC5SPRVPage[1]=MMC5SPRVPage[2]=MMC5SPRVPage[3]=MMC5SPRVPage[4]=MMC5SPRVPage[5]=MMC5SPRVPage[6]=MMC5SPRVPage[7]=&CHRptr[0][(V)<<13];}}
static INLINE void MMC5BGVROM_BANK8(uint32 V) {if(CHRptr[0]){V&=CHRmask8[0];MMC5BGVPage[0]=MMC5BGVPage[1]=MMC5BGVPage[2]=MMC5BGVPage[3]=MMC5BGVPage[4]=MMC5BGVPage[5]=MMC5BGVPage[6]=MMC5BGVPage[7]=&CHRptr[0][(V)<<13];}}
static uint8 PRGBanks[4];
static uint8 WRAMPage;
static uint8 CHRBanksA[8], CHRBanksB[4];
static uint8 WRAMMaskEnable[2];
static uint8 ABMode; /* A=0, B=1 */
static uint8 IRQScanline,IRQEnable;
static uint8 CHRMode, NTAMirroring, NTFill, ATFill;
static uint8 MMC5IRQR;
static uint8 MMC5LineCounter;
static uint8 mmc5psize, mmc5vsize;
static uint8 mul[2];
static uint8 *WRAM=NULL;
static uint8 *MMC5fill=NULL;
static uint8 *ExRAM=NULL;
static uint8 MMC5WRAMsize;
static uint8 MMC5WRAMIndex[8];
static uint8 MMC5ROMWrProtect[4];
static uint8 MMC5MemIn[5];
static void MMC5CHRA(void);
static void MMC5CHRB(void);
typedef struct __cartdata {
uint32 crc32;
uint8 size;
} cartdata;
// ETROM seems to have 16KB of WRAM, ELROM seems to have 8KB
// EWROM seems to have 32KB of WRAM
#define MMC5_NOCARTS 14
cartdata MMC5CartList[MMC5_NOCARTS]=
{
{0x9c18762b,2}, /* L'Empereur */
{0x26533405,2},
{0x6396b988,2},
{0xaca15643,2}, /* Uncharted Waters */
{0xfe3488d1,2}, /* Dai Koukai Jidai */
{0x15fe6d0f,2}, /* BKAC */
{0x39f2ce4b,2}, /* Suikoden */
{0x8ce478db,2}, /* Nobunaga's Ambition 2 */
{0xeee9a682,2},
{0x1ced086f,2}, /* Ishin no Arashi */
{0xf540677b,4}, /* Nobunaga...Bushou Fuuun Roku */
{0x6f4e4312,4}, /* Aoki Ookami..Genchou */
{0xf011e490,4}, /* Romance of the 3 Kingdoms 2 */
{0x184c2124,4}, /* Sangokushi 2 */
};
int DetectMMC5WRAMSize(uint32 crc32)
{
int x;
for(x=0;x<MMC5_NOCARTS;x++)
if(crc32==MMC5CartList[x].crc32)
{
FCEU_printf(" >8KB external WRAM present. Use UNIF if you hack the ROM image.\n");
return(MMC5CartList[x].size*8);
}
return(8);
}
static void BuildWRAMSizeTable(void)
{
int x;
for(x=0;x<8;x++)
{
switch(MMC5WRAMsize)
{
case 0: MMC5WRAMIndex[x]=255; break;
case 1: MMC5WRAMIndex[x]=(x>3)?255:0; break;
case 2: MMC5WRAMIndex[x]=(x&4)>>2; break;
case 4: MMC5WRAMIndex[x]=(x>3)?255:(x&3); break;
}
}
}
static void MMC5CHRA(void)
{
int x;
switch(mmc5vsize&3)
{
case 0: setchr8(CHRBanksA[7]);
MMC5SPRVROM_BANK8(CHRBanksA[7]);
break;
case 1: setchr4(0x0000,CHRBanksA[3]);
setchr4(0x1000,CHRBanksA[7]);
MMC5SPRVROM_BANK4(0x0000,CHRBanksA[3]);
MMC5SPRVROM_BANK4(0x1000,CHRBanksA[7]);
break;
case 2: setchr2(0x0000,CHRBanksA[1]);
setchr2(0x0800,CHRBanksA[3]);
setchr2(0x1000,CHRBanksA[5]);
setchr2(0x1800,CHRBanksA[7]);
MMC5SPRVROM_BANK2(0x0000,CHRBanksA[1]);
MMC5SPRVROM_BANK2(0x0800,CHRBanksA[3]);
MMC5SPRVROM_BANK2(0x1000,CHRBanksA[5]);
MMC5SPRVROM_BANK2(0x1800,CHRBanksA[7]);
break;
case 3: for(x=0;x<8;x++)
{
setchr1(x<<10,CHRBanksA[x]);
MMC5SPRVROM_BANK1(x<<10,CHRBanksA[x]);
}
break;
}
}
static void MMC5CHRB(void)
{
int x;
switch(mmc5vsize&3)
{
case 0: setchr8(CHRBanksB[3]);
MMC5BGVROM_BANK8(CHRBanksB[3]);
break;
case 1: setchr4(0x0000,CHRBanksB[3]);
setchr4(0x1000,CHRBanksB[3]);
MMC5BGVROM_BANK4(0x0000,CHRBanksB[3]);
MMC5BGVROM_BANK4(0x1000,CHRBanksB[3]);
break;
case 2: setchr2(0x0000,CHRBanksB[1]);
setchr2(0x0800,CHRBanksB[3]);
setchr2(0x1000,CHRBanksB[1]);
setchr2(0x1800,CHRBanksB[3]);
MMC5BGVROM_BANK2(0x0000,CHRBanksB[1]);
MMC5BGVROM_BANK2(0x0800,CHRBanksB[3]);
MMC5BGVROM_BANK2(0x1000,CHRBanksB[1]);
MMC5BGVROM_BANK2(0x1800,CHRBanksB[3]);
break;
case 3: for(x=0;x<8;x++)
{
setchr1(x<<10,CHRBanksB[x&3]);
MMC5BGVROM_BANK1(x<<10,CHRBanksB[x&3]);
}
break;
}
}
static void FASTAPASS(2) MMC5WRAM(uint32 A, uint32 V)
{
//printf("%02x\n",V);
V=MMC5WRAMIndex[V&7];
if(V!=255)
{
setprg8r(0x10,A,V);
MMC5MemIn[(A-0x6000)>>13]=1;
}
else
MMC5MemIn[(A-0x6000)>>13]=0;
}
static void MMC5PRG(void)
{
int x;
switch(mmc5psize&3)
{
case 0: MMC5ROMWrProtect[0]=MMC5ROMWrProtect[1]=
MMC5ROMWrProtect[2]=MMC5ROMWrProtect[3]=1;
setprg32(0x8000,((PRGBanks[1]&0x7F)>>2));
for(x=0;x<4;x++)
MMC5MemIn[1+x]=1;
break;
case 1: if(PRGBanks[1]&0x80)
{
MMC5ROMWrProtect[0]=MMC5ROMWrProtect[1]=1;
setprg16(0x8000,(PRGBanks[1]>>1));
MMC5MemIn[1]=MMC5MemIn[2]=1;
}
else
{
MMC5ROMWrProtect[0]=MMC5ROMWrProtect[1]=0;
MMC5WRAM(0x8000,PRGBanks[1]&7&0xFE);
MMC5WRAM(0xA000,(PRGBanks[1]&7&0xFE)+1);
}
MMC5MemIn[3]=MMC5MemIn[4]=1;
MMC5ROMWrProtect[2]=MMC5ROMWrProtect[3]=1;
setprg16(0xC000,(PRGBanks[3]&0x7F)>>1);
break;
case 2: if(PRGBanks[1]&0x80)
{
MMC5MemIn[1]=MMC5MemIn[2]=1;
MMC5ROMWrProtect[0]=MMC5ROMWrProtect[1]=1;
setprg16(0x8000,(PRGBanks[1]&0x7F)>>1);
}
else
{
MMC5ROMWrProtect[0]=MMC5ROMWrProtect[1]=0;
MMC5WRAM(0x8000,PRGBanks[1]&7&0xFE);
MMC5WRAM(0xA000,(PRGBanks[1]&7&0xFE)+1);
}
if(PRGBanks[2]&0x80)
{
MMC5ROMWrProtect[2]=1;
MMC5MemIn[3]=1;
setprg8(0xC000,PRGBanks[2]&0x7F);
}
else
{
MMC5ROMWrProtect[2]=0;
MMC5WRAM(0xC000,PRGBanks[2]&7);
}
MMC5MemIn[4]=1;
MMC5ROMWrProtect[3]=1;
setprg8(0xE000,PRGBanks[3]&0x7F);
break;
case 3: for(x=0;x<3;x++)
if(PRGBanks[x]&0x80)
{
MMC5ROMWrProtect[x]=1;
setprg8(0x8000+(x<<13),PRGBanks[x]&0x7F);
MMC5MemIn[1+x]=1;
}
else
{
MMC5ROMWrProtect[x]=0;
MMC5WRAM(0x8000+(x<<13),PRGBanks[x]&7);
}
MMC5MemIn[4]=1;
MMC5ROMWrProtect[3]=1;
setprg8(0xE000,PRGBanks[3]&0x7F);
break;
}
}
static DECLFW(Mapper5_write)
{
if(A>=0x5120&&A<=0x5127)
{
ABMode = 0;
CHRBanksA[A&7]=V;
MMC5CHRA();
}
else switch(A)
{
case 0x5105: {
int x;
for(x=0;x<4;x++)
{
switch((V>>(x<<1))&3)
{
case 0:PPUNTARAM|=1<<x;vnapage[x]=NTARAM;break;
case 1:PPUNTARAM|=1<<x;vnapage[x]=NTARAM+0x400;break;
case 2:PPUNTARAM|=1<<x;vnapage[x]=ExRAM;break;
case 3:PPUNTARAM&=~(1<<x);vnapage[x]=MMC5fill;break;
}
}
}
NTAMirroring=V;
break;
case 0x5113: WRAMPage=V;MMC5WRAM(0x6000,V&7);break;
case 0x5100: mmc5psize=V;MMC5PRG();break;
case 0x5101: mmc5vsize=V;
if(!ABMode)
{ MMC5CHRB();MMC5CHRA();}
else
{ MMC5CHRA();MMC5CHRB();}
break;
case 0x5114:
case 0x5115:
case 0x5116:
case 0x5117: PRGBanks[A&3]=V;MMC5PRG();break;
case 0x5128:
case 0x5129:
case 0x512a:
case 0x512b: ABMode=1;
CHRBanksB[A&3]=V;
MMC5CHRB();
break;
case 0x5102: WRAMMaskEnable[0]=V;break;
case 0x5103: WRAMMaskEnable[1]=V;break;
case 0x5104: CHRMode=V;MMC5HackCHRMode=V&3;break;
case 0x5106: if(V!=NTFill)
{
uint32 t;
t=V|(V<<8)|(V<<16)|(V<<24);
FCEU_dwmemset(MMC5fill,t,0x3c0);
}
NTFill=V;
break;
case 0x5107: if(V!=ATFill)
{
unsigned char moop;
uint32 t;
moop=V|(V<<2)|(V<<4)|(V<<6);
t=moop|(moop<<8)|(moop<<16)|(moop<<24);
FCEU_dwmemset(MMC5fill+0x3c0,t,0x40);
}
ATFill=V;
break;
case 0x5200: MMC5HackSPMode=V;break;
case 0x5201: MMC5HackSPScroll=(V>>3)&0x1F;break;
case 0x5202: MMC5HackSPPage=V&0x3F;break;
case 0x5203: X6502_IRQEnd(FCEU_IQEXT);IRQScanline=V;break;
case 0x5204: X6502_IRQEnd(FCEU_IQEXT);IRQEnable=V&0x80;break;
case 0x5205: mul[0]=V;break;
case 0x5206: mul[1]=V;break;
}
}
static DECLFR(MMC5_ReadROMRAM)
{
if(MMC5MemIn[(A-0x6000)>>13])
return Page[A>>11][A];
else
return X.DB;
}
static DECLFW(MMC5_WriteROMRAM)
{
if(A>=0x8000)
if(MMC5ROMWrProtect[(A-0x8000)>>13]) return;
if(MMC5MemIn[(A-0x6000)>>13])
if(((WRAMMaskEnable[0]&3)|((WRAMMaskEnable[1]&3)<<2)) == 6) Page[A>>11][A]=V;
}
static DECLFW(MMC5_ExRAMWr)
{
if(MMC5HackCHRMode!=3)
ExRAM[A&0x3ff]=V;
}
static DECLFR(MMC5_ExRAMRd)
{
/* Not sure if this is correct, so I'll comment it out for now. */
//if(MMC5HackCHRMode>=2)
return ExRAM[A&0x3ff];
//else
// return(X.DB);
}
static DECLFR(MMC5_read)
{
switch(A)
{
case 0x5204: X6502_IRQEnd(FCEU_IQEXT);
{
uint8 x;
x=MMC5IRQR;
if(!fceuindbg)
MMC5IRQR&=0x40;
return x;
}
case 0x5205: return (mul[0]*mul[1]);
case 0x5206: return ((mul[0]*mul[1])>>8);
}
return(X.DB);
}
void MMC5Synco(void)
{
int x;
MMC5PRG();
for(x=0;x<4;x++)
{
switch((NTAMirroring>>(x<<1))&3)
{
case 0:PPUNTARAM|=1<<x;vnapage[x]=NTARAM;break;
case 1:PPUNTARAM|=1<<x;vnapage[x]=NTARAM+0x400;break;
case 2:PPUNTARAM|=1<<x;vnapage[x]=ExRAM;break;
case 3:PPUNTARAM&=~(1<<x);vnapage[x]=MMC5fill;break;
}
}
MMC5WRAM(0x6000,WRAMPage&7);
if(!ABMode)
{
MMC5CHRB();
MMC5CHRA();
}
else
{
MMC5CHRA();
MMC5CHRB();
}
{
uint32 t;
t=NTFill|(NTFill<<8)|(NTFill<<16)|(NTFill<<24);
FCEU_dwmemset(MMC5fill,t,0x3c0);
}
{
unsigned char moop;
uint32 t;
moop=ATFill|(ATFill<<2)|(ATFill<<4)|(ATFill<<6);
t=moop|(moop<<8)|(moop<<16)|(moop<<24);
FCEU_dwmemset(MMC5fill+0x3c0,t,0x40);
}
X6502_IRQEnd(FCEU_IQEXT);
MMC5HackCHRMode=CHRMode&3;
}
void MMC5_hb(int scanline)
{
if(scanline==240)
{
MMC5LineCounter=0;
MMC5IRQR=0x40;
return;
}
if(MMC5LineCounter<240)
{
if(MMC5LineCounter==IRQScanline)
{
MMC5IRQR|=0x80;
if(IRQEnable&0x80)
X6502_IRQBegin(FCEU_IQEXT);
}
MMC5LineCounter++;
}
if(MMC5LineCounter==240)
MMC5IRQR=0;
}
void MMC5_StateRestore(int version)
{
MMC5Synco();
}
typedef struct {
uint16 wl[2];
uint8 env[2];
uint8 enable;
uint8 running;
uint8 raw;
uint8 rawcontrol;
int32 dcount[2];
int32 BC[3];
int32 vcount[2];
} MMC5APU;
static MMC5APU MMC5Sound;
static void Do5PCM()
{
int32 V;
int32 start,end;
start=MMC5Sound.BC[2];
end=(SOUNDTS<<16)/soundtsinc;
if(end<=start) return;
MMC5Sound.BC[2]=end;
if(!(MMC5Sound.rawcontrol&0x40) && MMC5Sound.raw)
for(V=start;V<end;V++)
Wave[V>>4]+=MMC5Sound.raw<<1;
}
static void Do5PCMHQ()
{
int32 V;
if(!(MMC5Sound.rawcontrol&0x40) && MMC5Sound.raw)
for(V=MMC5Sound.BC[2];V<SOUNDTS;V++)
WaveHi[V]+=MMC5Sound.raw<<5;
MMC5Sound.BC[2]=SOUNDTS;
}
static DECLFW(Mapper5_SW)
{
A&=0x1F;
GameExpSound.Fill=MMC5RunSound;
GameExpSound.HiFill=MMC5RunSoundHQ;
switch(A)
{
case 0x10:if(psfun) psfun();MMC5Sound.rawcontrol=V;break;
case 0x11:if(psfun) psfun();MMC5Sound.raw=V;break;
case 0x0:
case 0x4://printf("%04x:$%02x\n",A,V&0x30);
if(sfun) sfun(A>>2);
MMC5Sound.env[A>>2]=V;
break;
case 0x2:
case 0x6: if(sfun) sfun(A>>2);
MMC5Sound.wl[A>>2]&=~0x00FF;
MMC5Sound.wl[A>>2]|=V&0xFF;
break;
case 0x3:
case 0x7://printf("%04x:$%02x\n",A,V>>3);
MMC5Sound.wl[A>>2]&=~0x0700;
MMC5Sound.wl[A>>2]|=(V&0x07)<<8;
MMC5Sound.running|=1<<(A>>2);
break;
case 0x15:if(sfun)
{
sfun(0);
sfun(1);
}
MMC5Sound.running&=V;
MMC5Sound.enable=V;
//printf("%02x\n",V);
break;
}
}
static void Do5SQ(int P)
{
static int tal[4]={1,2,4,6};
int32 V,amp,rthresh,wl;
int32 start,end;
start=MMC5Sound.BC[P];
end=(SOUNDTS<<16)/soundtsinc;
if(end<=start) return;
MMC5Sound.BC[P]=end;
wl=MMC5Sound.wl[P]+1;
amp=(MMC5Sound.env[P]&0xF)<<4;
rthresh=tal[(MMC5Sound.env[P]&0xC0)>>6];
if(wl>=8 && (MMC5Sound.running&(P+1)))
{
int dc,vc;
wl<<=18;
dc=MMC5Sound.dcount[P];
vc=MMC5Sound.vcount[P];
for(V=start;V<end;V++)
{
if(dc<rthresh)
Wave[V>>4]+=amp;
vc-=nesincsize;
while(vc<=0)
{
vc+=wl;
dc=(dc+1)&7;
}
}
MMC5Sound.dcount[P]=dc;
MMC5Sound.vcount[P]=vc;
}
}
static void Do5SQHQ(int P)
{
static int tal[4]={1,2,4,6};
int32 V,amp,rthresh,wl;
wl=MMC5Sound.wl[P]+1;
amp=((MMC5Sound.env[P]&0xF)<<8);
rthresh=tal[(MMC5Sound.env[P]&0xC0)>>6];
if(wl>=8 && (MMC5Sound.running&(P+1)))
{
int dc,vc;
wl<<=1;
dc=MMC5Sound.dcount[P];
vc=MMC5Sound.vcount[P];
for(V=MMC5Sound.BC[P];V<SOUNDTS;V++)
{
if(dc<rthresh)
WaveHi[V]+=amp;
vc--;
if(vc<=0) /* Less than zero when first started. */
{
vc=wl;
dc=(dc+1)&7;
}
}
MMC5Sound.dcount[P]=dc;
MMC5Sound.vcount[P]=vc;
}
MMC5Sound.BC[P]=SOUNDTS;
}
void MMC5RunSoundHQ(void)
{
Do5SQHQ(0);
Do5SQHQ(1);
Do5PCMHQ();
}
void MMC5HiSync(int32 ts)
{
int x;
for(x=0;x<3;x++) MMC5Sound.BC[x]=ts;
}
void MMC5RunSound(int Count)
{
int x;
Do5SQ(0);
Do5SQ(1);
Do5PCM();
for(x=0;x<3;x++)
MMC5Sound.BC[x]=Count;
}
void Mapper5_ESI(void)
{
GameExpSound.RChange=Mapper5_ESI;
if(FSettings.SndRate)
{
if(FSettings.soundq>=1)
{
sfun=Do5SQHQ;
psfun=Do5PCMHQ;
}
else
{
sfun=Do5SQ;
psfun=Do5PCM;
}
}
else
{
sfun=0;
psfun=0;
}
memset(MMC5Sound.BC,0,sizeof(MMC5Sound.BC));
memset(MMC5Sound.vcount,0,sizeof(MMC5Sound.vcount));
GameExpSound.HiSync=MMC5HiSync;
}
void NSFMMC5_Init(void)
{
memset(&MMC5Sound,0,sizeof(MMC5Sound));
mul[0]=mul[1]=0;
ExRAM=(uint8*)FCEU_gmalloc(1024);
Mapper5_ESI();
SetWriteHandler(0x5c00,0x5fef,MMC5_ExRAMWr);
SetReadHandler(0x5c00,0x5fef,MMC5_ExRAMRd);
MMC5HackCHRMode=2;
SetWriteHandler(0x5000,0x5015,Mapper5_SW);
SetWriteHandler(0x5205,0x5206,Mapper5_write);
SetReadHandler(0x5205,0x5206,MMC5_read);
}
void NSFMMC5_Close(void)
{
FCEU_gfree(ExRAM);
ExRAM=0;
}
static void GenMMC5Reset(void)
{
int x;
for(x=0;x<4;x++) PRGBanks[x]=~0;
for(x=0;x<8;x++) CHRBanksA[x]=~0;
for(x=0;x<4;x++) CHRBanksB[x]=~0;
WRAMMaskEnable[0]=WRAMMaskEnable[1]=~0;
mmc5psize=mmc5vsize=3;
CHRMode=0;
NTAMirroring=NTFill=ATFill=0xFF;
MMC5Synco();
SetWriteHandler(0x4020,0x5bff,Mapper5_write);
SetReadHandler(0x4020,0x5bff,MMC5_read);
SetWriteHandler(0x5c00,0x5fff,MMC5_ExRAMWr);
SetReadHandler(0x5c00,0x5fff,MMC5_ExRAMRd);
SetWriteHandler(0x6000,0xFFFF,MMC5_WriteROMRAM);
SetReadHandler(0x6000,0xFFFF,MMC5_ReadROMRAM);
SetWriteHandler(0x5000,0x5015,Mapper5_SW);
SetWriteHandler(0x5205,0x5206,Mapper5_write);
SetReadHandler(0x5205,0x5206,MMC5_read);
//GameHBIRQHook=MMC5_hb;
FCEU_CheatAddRAM(8,0x6000,WRAM);
FCEU_CheatAddRAM(1,0x5c00,ExRAM);
}
static SFORMAT MMC5_StateRegs[]={
{ PRGBanks, 4, "PRGB"},
{ CHRBanksA, 8, "CHRA"},
{ CHRBanksB, 4, "CHRB"},
{ &WRAMPage, 1, "WRMP"},
{ WRAMMaskEnable, 2, "WRME"},
{ &ABMode, 1, "ABMD"},
{ &IRQScanline, 1, "IRQS"},
{ &IRQEnable, 1, "IRQE"},
{ &CHRMode, 1, "CHRM"},
{ &NTAMirroring, 1, "NTAM"},
{ &NTFill, 1, "NTFL"},
{ &ATFill, 1, "ATFL"},
{ &MMC5Sound.wl[0], 2|FCEUSTATE_RLSB, "SDW0"},
{ &MMC5Sound.wl[1], 2|FCEUSTATE_RLSB, "SDW1"},
{ MMC5Sound.env, 2, "SDEV"},
{ &MMC5Sound.enable, 1, "SDEN"},
{ &MMC5Sound.running, 1, "SDRU"},
{ &MMC5Sound.raw, 1, "SDRW"},
{ &MMC5Sound.rawcontrol, 1, "SDRC"},
{0}
};
static void GenMMC5_Init(CartInfo *info, int wsize, int battery)
{
if(wsize)
{
WRAM=(uint8*)FCEU_gmalloc(wsize*1024);
SetupCartPRGMapping(0x10,WRAM,wsize*1024,1);
AddExState(WRAM, wsize*1024, 0, "WRAM");
}
MMC5fill=(uint8*)FCEU_gmalloc(1024);
ExRAM=(uint8*)FCEU_gmalloc(1024);
AddExState(MMC5_StateRegs, ~0, 0, 0);
AddExState(WRAM, wsize*1024, 0, "WRAM");
AddExState(ExRAM, 1024, 0, "ERAM");
AddExState(&MMC5HackSPMode, 1, 0, "SPLM");
AddExState(&MMC5HackSPScroll, 1, 0, "SPLS");
AddExState(&MMC5HackSPPage, 1, 0, "SPLP");
MMC5WRAMsize=wsize/8;
BuildWRAMSizeTable();
GameStateRestore=MMC5_StateRestore;
info->Power=GenMMC5Reset;
if(battery)
{
info->SaveGame[0]=WRAM;
if(wsize<=16)
info->SaveGameLen[0]=8192;
else
info->SaveGameLen[0]=32768;
}
MMC5HackVROMMask=CHRmask4[0];
MMC5HackExNTARAMPtr=ExRAM;
MMC5Hack=1;
MMC5HackVROMPTR=CHRptr[0];
MMC5HackCHRMode=0;
MMC5HackSPMode=MMC5HackSPScroll=MMC5HackSPPage=0;
Mapper5_ESI();
}
void Mapper5_Init(CartInfo *info)
{
GenMMC5_Init(info, DetectMMC5WRAMSize(info->CRC32), info->battery);
}
// ELROM seems to have 0KB of WRAM
// EKROM seems to have 8KB of WRAM
// ETROM seems to have 16KB of WRAM
// EWROM seems to have 32KB of WRAM
// ETROM and EWROM are battery-backed, EKROM isn't.
void ETROM_Init(CartInfo *info)
{
GenMMC5_Init(info, 16,info->battery);
}
void ELROM_Init(CartInfo *info)
{
GenMMC5_Init(info,0,0);
}
void EWROM_Init(CartInfo *info)
{
GenMMC5_Init(info,32,info->battery);
}
void EKROM_Init(CartInfo *info)
{
GenMMC5_Init(info,8,info->battery);
}

View File

@ -1,469 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static uint16 IRQCount;
static uint8 IRQa;
static uint8 WRAM[8192];
static uint8 IRAM[128];
static DECLFR(AWRAM)
{
return(WRAM[A-0x6000]);
}
static DECLFW(BWRAM)
{
WRAM[A-0x6000]=V;
}
void Mapper19_ESI(void);
static uint8 NTAPage[4];
static uint8 dopol;
static uint8 gorfus;
static uint8 gorko;
static void NamcoSound(int Count);
static void NamcoSoundHack(void);
static void DoNamcoSound(int32 *Wave, int Count);
static void DoNamcoSoundHQ(void);
static void SyncHQ(int32 ts);
static int is210; /* Lesser mapper. */
static uint8 PRG[3];
static uint8 CHR[8];
static SFORMAT N106_StateRegs[]={
{PRG,3,"PRG"},
{CHR,8,"CHR"},
{NTAPage,4,"NTA"},
{0}
};
static void SyncPRG(void)
{
setprg8(0x8000,PRG[0]);
setprg8(0xa000,PRG[1]);
setprg8(0xc000,PRG[2]);
setprg8(0xe000,0x3F);
}
static void FP_FASTAPASS(1) NamcoIRQHook(int a)
{
if(IRQa)
{
IRQCount+=a;
if(IRQCount>=0x7FFF)
{
X6502_IRQBegin(FCEU_IQEXT);
IRQa=0;
IRQCount=0x7FFF; //7FFF;
}
}
}
static DECLFR(Namco_Read4800)
{
uint8 ret=IRAM[dopol&0x7f];
/* Maybe I should call NamcoSoundHack() here? */
if(!fceuindbg)
if(dopol&0x80)
dopol=(dopol&0x80)|((dopol+1)&0x7f);
return ret;
}
static DECLFR(Namco_Read5000)
{
return(IRQCount);
}
static DECLFR(Namco_Read5800)
{
return(IRQCount>>8);
}
static void FASTAPASS(2) DoNTARAMROM(int w, uint8 V)
{
NTAPage[w]=V;
if(V>=0xE0)
setntamem(NTARAM+((V&1)<<10), 1, w);
else
{
V&=CHRmask1[0];
setntamem(CHRptr[0]+(V<<10), 0, w);
}
}
static void FixNTAR(void)
{
int x;
for(x=0;x<4;x++)
DoNTARAMROM(x,NTAPage[x]);
}
static void FASTAPASS(2) DoCHRRAMROM(int x, uint8 V)
{
CHR[x]=V;
if(!is210 && !((gorfus>>((x>>2)+6))&1) && (V>=0xE0))
{
// printf("BLAHAHA: %d, %02x\n",x,V);
//setchr1r(0x10,x<<10,V&7);
}
else
setchr1(x<<10,V);
}
static void FixCRR(void)
{
int x;
for(x=0;x<8;x++)
DoCHRRAMROM(x,CHR[x]);
}
static DECLFW(Mapper19C0D8_write)
{
DoNTARAMROM((A-0xC000)>>11,V);
}
static uint32 FreqCache[8];
static uint32 EnvCache[8];
static uint32 LengthCache[8];
static void FixCache(int a,int V)
{
int w=(a>>3)&0x7;
switch(a&0x07)
{
case 0x00:FreqCache[w]&=~0x000000FF;FreqCache[w]|=V;break;
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;
break;
case 0x07:EnvCache[w]=(double)(V&0xF)*576716;break;
}
}
static DECLFW(Mapper19_write)
{
A&=0xF800;
if(A>=0x8000 && A<=0xb800)
DoCHRRAMROM((A-0x8000)>>11,V);
else switch(A)
{
case 0x4800:
if(dopol&0x40)
{
if(FSettings.SndRate)
{
NamcoSoundHack();
GameExpSound.Fill=NamcoSound;
GameExpSound.HiFill=DoNamcoSoundHQ;
GameExpSound.HiSync=SyncHQ;
}
FixCache(dopol,V);
}
IRAM[dopol&0x7f]=V;
if(dopol&0x80)
dopol=(dopol&0x80)|((dopol+1)&0x7f);
break;
case 0xf800:
dopol=V;break;
case 0x5000:
IRQCount&=0xFF00;IRQCount|=V;X6502_IRQEnd(FCEU_IQEXT);break;
case 0x5800:
IRQCount&=0x00ff;IRQCount|=(V&0x7F)<<8;
IRQa=V&0x80;
X6502_IRQEnd(FCEU_IQEXT);
break;
case 0xE000:
gorko=V&0xC0;
PRG[0]=V&0x3F;
SyncPRG();
break;
case 0xE800:
gorfus=V&0xC0;
FixCRR();
PRG[1]=V&0x3F;
SyncPRG();
break;
case 0xF000:
PRG[2]=V&0x3F;
SyncPRG();
break;
}
}
static int dwave=0;
static void NamcoSoundHack(void)
{
int32 z,a;
if(FSettings.soundq>=1)
{
DoNamcoSoundHQ();
return;
}
z=((SOUNDTS<<16)/soundtsinc)>>4;
a=z-dwave;
if(a) DoNamcoSound(&Wave[dwave], a);
dwave+=a;
}
static void NamcoSound(int Count)
{
int32 z,a;
z=((SOUNDTS<<16)/soundtsinc)>>4;
a=z-dwave;
if(a) DoNamcoSound(&Wave[dwave], a);
dwave=0;
}
static uint32 PlayIndex[8];
static int32 vcount[8];
static int32 CVBC;
#define TOINDEX (16+1)
// 16:15
static void SyncHQ(int32 ts)
{
CVBC=ts;
}
/* Things to do:
1 Read freq low
2 Read freq mid
3 Read freq high
4 Read envelope
...?
*/
static INLINE uint32 FetchDuff(uint32 P, uint32 envelope)
{
uint32 duff;
duff=IRAM[((IRAM[0x46+(P<<3)]+(PlayIndex[P]>>TOINDEX))&0xFF)>>1];
if((IRAM[0x46+(P<<3)]+(PlayIndex[P]>>TOINDEX))&1)
duff>>=4;
duff&=0xF;
duff=(duff*envelope)>>16;
return(duff);
}
static void DoNamcoSoundHQ(void)
{
int32 P,V;
int32 cyclesuck=(((IRAM[0x7F]>>4)&7)+1)*15;
for(P=7;P>=(7-((IRAM[0x7F]>>4)&7));P--)
{
if((IRAM[0x44+(P<<3)]&0xE0) && (IRAM[0x47+(P<<3)]&0xF))
{
uint32 freq;
int32 vco;
uint32 duff2,lengo,envelope;
vco=vcount[P];
freq=FreqCache[P];
envelope=EnvCache[P];
lengo=LengthCache[P];
duff2=FetchDuff(P,envelope);
for(V=CVBC<<1;V<SOUNDTS<<1;V++)
{
WaveHi[V>>1]+=duff2;
if(!vco)
{
PlayIndex[P]+=freq;
while((PlayIndex[P]>>TOINDEX)>=lengo) PlayIndex[P]-=lengo<<TOINDEX;
duff2=FetchDuff(P,envelope);
vco=cyclesuck;
}
vco--;
}
vcount[P]=vco;
}
}
CVBC=SOUNDTS;
}
static void DoNamcoSound(int32 *Wave, int Count)
{
int P,V;
for(P=7;P>=7-((IRAM[0x7F]>>4)&7);P--)
{
if((IRAM[0x44+(P<<3)]&0xE0) && (IRAM[0x47+(P<<3)]&0xF))
{
int32 inc;
uint32 freq;
int32 vco;
uint32 duff,duff2,lengo,envelope;
vco=vcount[P];
freq=FreqCache[P];
envelope=EnvCache[P];
lengo=LengthCache[P];
if(!freq) {/*printf("Ack");*/ continue;}
{
int c=((IRAM[0x7F]>>4)&7)+1;
inc=(long double)(FSettings.SndRate<<15)/((long double)freq*21477272/((long double)0x400000*c*45));
}
duff=IRAM[(((IRAM[0x46+(P<<3)]+PlayIndex[P])&0xFF)>>1)];
if((IRAM[0x46+(P<<3)]+PlayIndex[P])&1)
duff>>=4;
duff&=0xF;
duff2=(duff*envelope)>>19;
for(V=0;V<Count*16;V++)
{
if(vco>=inc)
{
PlayIndex[P]++;
if(PlayIndex[P]>=lengo)
PlayIndex[P]=0;
vco-=inc;
duff=IRAM[(((IRAM[0x46+(P<<3)]+PlayIndex[P])&0xFF)>>1)];
if((IRAM[0x46+(P<<3)]+PlayIndex[P])&1)
duff>>=4;
duff&=0xF;
duff2=(duff*envelope)>>19;
}
Wave[V>>4]+=duff2;
vco+=0x8000;
}
vcount[P]=vco;
}
}
}
static void Mapper19_StateRestore(int version)
{
SyncPRG();
FixNTAR();
FixCRR();
int x;
for(x=0x40;x<0x80;x++)
FixCache(x,IRAM[x]);
}
static void M19SC(void)
{
if(FSettings.SndRate)
Mapper19_ESI();
}
void Mapper19_ESI(void)
{
GameExpSound.RChange=M19SC;
memset(vcount,0,sizeof(vcount));
memset(PlayIndex,0,sizeof(PlayIndex));
CVBC=0;
}
void NSFN106_Init(void)
{
SetWriteHandler(0xf800,0xffff,Mapper19_write);
SetWriteHandler(0x4800,0x4fff,Mapper19_write);
SetReadHandler(0x4800,0x4fff,Namco_Read4800);
Mapper19_ESI();
}
static int battery=0;
static void N106_Power(void)
{
int x;
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x8000,0xffff,Mapper19_write);
SetWriteHandler(0x4020,0x5fff,Mapper19_write);
if(!is210)
{
SetWriteHandler(0xc000,0xdfff,Mapper19C0D8_write);
SetReadHandler(0x4800,0x4fff,Namco_Read4800);
SetReadHandler(0x5000,0x57ff,Namco_Read5000);
SetReadHandler(0x5800,0x5fff,Namco_Read5800);
NTAPage[0]=NTAPage[1]=NTAPage[2]=NTAPage[3]=0xFF;
FixNTAR();
}
SetReadHandler(0x6000,0x7FFF,AWRAM);
SetWriteHandler(0x6000,0x7FFF,BWRAM);
FCEU_CheatAddRAM(8,0x6000,WRAM);
gorfus=0xFF;
SyncPRG();
FixCRR();
if(!battery)
{
FCEU_dwmemset(WRAM,0,8192);
FCEU_dwmemset(IRAM,0,128);
}
for(x=0x40;x<0x80;x++)
FixCache(x,IRAM[x]);
}
void Mapper19_Init(CartInfo *info)
{
is210=0;
battery=info->battery;
info->Power=N106_Power;
MapIRQHook=NamcoIRQHook;
GameStateRestore=Mapper19_StateRestore;
GameExpSound.RChange=M19SC;
if(FSettings.SndRate)
Mapper19_ESI();
AddExState(WRAM, 8192, 0, "WRAM");
AddExState(IRAM, 128, 0, "WRAM");
AddExState(N106_StateRegs, ~0, 0, 0);
if(info->battery)
{
info->SaveGame[0]=WRAM;
info->SaveGameLen[0]=8192;
info->SaveGame[1]=IRAM;
info->SaveGameLen[1]=128;
}
}
static void Mapper210_StateRestore(int version)
{
SyncPRG();
FixCRR();
}
void Mapper210_Init(CartInfo *info)
{
is210=1;
GameStateRestore=Mapper210_StateRestore;
info->Power=N106_Power;
AddExState(WRAM, 8192, 0, "WRAM");
}

View File

@ -1,398 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static uint8 cmd;
static uint8 latch[8];
static void S74LS374MSync(uint8 mirr)
{
switch(mirr&3)
{
case 0:setmirror(MI_V);break;
case 1:setmirror(MI_H);break;
case 2:setmirrorw(0,1,1,1);break;
case 3:setmirror(MI_0);break;
}
}
static void S74LS374NSynco(void)
{
setprg32(0x8000,latch[0]);
setchr8(latch[1]|latch[3]|latch[4]);
S74LS374MSync(latch[2]);
}
static DECLFW(S74LS374NWrite)
{
A&=0x4101;
if(A==0x4100)
cmd=V&7;
else
{
switch(cmd)
{
case 2:latch[0]=V&1; latch[3]=(V&1)<<3;break;
case 4:latch[4]=(V&1)<<2;break;
case 5:latch[0]=V&7;break;
case 6:latch[1]=V&3;break;
case 7:latch[2]=V>>1;break;
}
S74LS374NSynco();
}
}
static DECLFR(S74LS374NRead)
{
uint8 ret;
if((A&0x4100)==0x4100)
ret=(X.DB&0xC0)|((~cmd)&0x3F);
else
ret=X.DB;
return ret;
}
static void S74LS374NPower(void)
{
latch[0]=latch[1]=latch[2]=latch[3]=latch[4]=0;
S74LS374NSynco();
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x4100,0x7FFF,S74LS374NWrite);
SetReadHandler(0x4100,0x5fff,S74LS374NRead);
}
static void S74LS374NRestore(int version)
{
S74LS374NSynco();
}
void S74LS374N_Init(CartInfo *info)
{
info->Power=S74LS374NPower;
GameStateRestore=S74LS374NRestore;
AddExState(latch, 5, 0, "LATC");
AddExState(&cmd, 1, 0, "CMD");
}
static void S74LS374NASynco(void)
{
setprg32(0x8000,latch[0]);
setchr8(latch[1]);
S74LS374MSync(latch[2]);
}
static DECLFW(S74LS374NAWrite)
{
A&=0x4101;
if(A==0x4100)
cmd=V&7;
else
{
switch(cmd)
{
case 0:latch[0]=0;latch[1]=3;break;
case 2:latch[3]=(V&1)<<3;break;
case 4:latch[1]=(latch[1]&6)|(V&3);break;
case 5:latch[0]=V&1;break;
case 6:latch[1]=(latch[1]&1)|latch[3]|((V&3)<<1);break;
case 7:latch[2]=V&1;break;
}
S74LS374NASynco();
}
}
static void S74LS374NAPower(void)
{
latch[0]=latch[2]=latch[3]=latch[4]=0;
latch[1]=3;
S74LS374NASynco();
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x4100,0x7FFF,S74LS374NAWrite);
}
void S74LS374NA_Init(CartInfo *info)
{
info->Power=S74LS374NAPower;
GameStateRestore=S74LS374NRestore;
AddExState(latch, 5, 0, "LATC");
AddExState(&cmd, 1, 0, "CMD");
}
static int type;
static void S8259Synco(void)
{
int x;
setprg32(0x8000,latch[5]&7);
if(!UNIFchrrama) // No CHR RAM? Then BS'ing is ok.
{
for(x=0;x<4;x++)
{
int bank;
if(latch[7]&1)
bank=(latch[0]&0x7)|((latch[4]&7)<<3);
else
bank=(latch[x]&0x7)|((latch[4]&7)<<3);
switch (type)
{
case 00: bank=(bank<<1)|(x&1); setchr2(0x800*x,bank); break;
case 01: setchr2(0x800*x,bank); break;
case 02: bank=(bank<<2)|(x&3); setchr2(0x800*x,bank); break;
case 03: bank=latch[x]&7;
switch (x&3)
{
case 01: bank|=(latch[4]&1)<<4;break;
case 02: bank|=(latch[4]&2)<<3;break;
case 03: bank|=((latch[4]&4)<<2)|((latch[6]&1)<<3);break;
}
setchr1(0x400*x,bank);
setchr4(0x1000,~0);
break;
}
}
}
if(!(latch[7]&1))
S74LS374MSync(latch[7]>>1);
else
setmirror(MI_V);
}
static DECLFW(S8259Write)
{
A&=0x4101;
if(A==0x4100)
cmd=V;
else
{
latch[cmd&7]=V;
S8259Synco();
}
}
static void S8259Reset(void)
{
int x;
cmd=0;
for(x=0;x<8;x++) latch[x]=0;
setchr8(0);
S8259Synco();
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x4100,0x7FFF,S8259Write);
}
static void S8259Restore(int version)
{
S8259Synco();
}
void S8259A_Init(CartInfo *info) // Kevin's Horton 141 mapper
{
info->Power=S8259Reset;
GameStateRestore=S8259Restore;
AddExState(latch, 8, 0, "LATC");
AddExState(&cmd, 1, 0, "CMD");
type=0;
}
void S8259B_Init(CartInfo *info) // Kevin's Horton 138 mapper
{
info->Power=S8259Reset;
GameStateRestore=S8259Restore;
AddExState(latch, 8, 0, "LATC");
AddExState(&cmd, 1, 0, "CMD");
type=1;
}
void S8259C_Init(CartInfo *info) // Kevin's Horton 139 mapper
{
info->Power=S8259Reset;
GameStateRestore=S8259Restore;
AddExState(latch, 8, 0, "LATC");
AddExState(&cmd, 1, 0, "CMD");
type=2;
}
void S8259D_Init(CartInfo *info) // Kevin's Horton 137 mapper
{
info->Power=S8259Reset;
GameStateRestore=S8259Restore;
AddExState(latch, 8, 0, "LATC");
AddExState(&cmd, 1, 0, "CMD");
type=3;
}
static void(*WSync)(void);
static DECLFW(SAWrite)
{
if(A&0x100)
{
latch[0]=V;
WSync();
}
}
static void SAPower(void)
{
latch[0]=0;
WSync();
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x4100,0x5FFF,SAWrite);
}
static void SARestore(int version)
{
WSync();
}
static DECLFW(SADWrite)
{
latch[0]=V;
WSync();
}
static void SADPower(void)
{
latch[0]=0;
WSync();
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x8000,0xFFFF,SADWrite);
}
static void SA0161MSynco()
{
setprg32(0x8000,(latch[0]>>3)&1);
setchr8(latch[0]&7);
}
static void SA72007Synco()
{
setprg32(0x8000,0);
setchr8(latch[0]>>7);
}
static void SA72008Synco()
{
setprg32(0x8000,(latch[0]>>2)&1);
setchr8(latch[0]&3);
}
void SA0161M_Init(CartInfo *info)
{
WSync=SA0161MSynco;
GameStateRestore=SARestore;
info->Power=SAPower;
AddExState(&latch[0], 1, 0, "LATC");
}
void SA72007_Init(CartInfo *info)
{
WSync=SA72007Synco;
GameStateRestore=SARestore;
info->Power=SAPower;
AddExState(&latch[0], 1, 0, "LATC");
}
void SA72008_Init(CartInfo *info)
{
WSync=SA72008Synco;
GameStateRestore=SARestore;
info->Power=SAPower;
AddExState(&latch[0], 1, 0, "LATC");
}
void SA0036_Init(CartInfo *info)
{
WSync=SA72007Synco;
GameStateRestore=SARestore;
info->Power=SADPower;
AddExState(&latch[0], 1, 0, "LATC");
}
void SA0037_Init(CartInfo *info)
{
WSync=SA0161MSynco;
GameStateRestore=SARestore;
info->Power=SADPower;
AddExState(&latch[0], 1, 0, "LATC");
}
static void TCU01Synco()
{
setprg32(0x8000,(latch[0]>>2)&1);
setchr8((latch[0]>>3)&0xF);
}
static DECLFW(TCWrite)
{
if((A&0x103)==0x102)
{
latch[0]=V;
TCU01Synco();
}
}
static void TCU01Reset(void)
{
latch[0]=0;
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x4100,0xFFFF,TCWrite);
TCU01Synco();
}
static void TCU01Restore(int version)
{
TCU01Synco();
}
void TCU01_Init(CartInfo *info)
{
GameStateRestore=TCU01Restore;
info->Power=TCU01Reset;
AddExState(&latch[0], 1, 0, "LATC");
}
static DECLFR(TCA01Read)
{
uint8 ret;
if((A&0x4100)==0x4100)
ret=(X.DB&0xC0)|((~A)&0x3F);
else
ret=X.DB;
return ret;
}
static void TCA01Reset(void)
{
setprg16(0x8000,0);
setprg16(0xC000,1);
setchr8(0);
SetReadHandler(0x8000,0xFFFF,CartBR);
SetReadHandler(0x4100,0x5FFF,TCA01Read);
}
void TCA01_Init(CartInfo *info)
{
info->Power=TCA01Reset;
}

View File

@ -1,86 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2006 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
#include "mmc3.h"
static uint8 *CHRRAM;
static uint8 tekker;
static void MSHCW(uint32 A, uint8 V)
{
if(EXPREGS[0]&0x40)
setchr8r(0x10,0);
else
{
if(A<0x800)
setchr1(A,V|((EXPREGS[0]&8)<<5));
else if(A<0x1000)
setchr1(A,V|((EXPREGS[0]&4)<<6));
else if(A<0x1800)
setchr1(A,V|((EXPREGS[0]&1)<<8));
else
setchr1(A,V|((EXPREGS[0]&2)<<7));
}
}
static DECLFW(MSHWrite)
{
EXPREGS[0]=V;
FixMMC3CHR(MMC3_cmd);
}
static DECLFR(MSHRead)
{
return(tekker);
}
static void MSHReset(void)
{
MMC3RegReset();
tekker^=0xFF;
}
static void MSHPower(void)
{
tekker=0x00;
GenMMC3Power();
SetWriteHandler(0x4100,0x4100,MSHWrite);
SetReadHandler(0x4100,0x4100,MSHRead);
}
static void MSHClose(void)
{
if(CHRRAM)
FCEU_gfree(CHRRAM);
CHRRAM=NULL;
}
void UNLSHeroes_Init(CartInfo *info)
{
GenMMC3_Init(info, 256, 512, 0, 0);
cwrap=MSHCW;
info->Power=MSHPower;
info->Reset=MSHReset;
info->Close=MSHClose;
CHRRAM = (uint8*)FCEU_gmalloc(8192);
SetupCartCHRMapping(0x10, CHRRAM, 8192, 1);
AddExState(EXPREGS, 4, 0, "EXPR");
}

View File

@ -1,159 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static uint8 chrcmd[8], prg0, prg1, brk, mirr;
static uint8 reg[8], cmd;
static uint8 IRQCount,IRQLatch,IRQa;
static uint8 IRQReload;
static SFORMAT StateRegs[]=
{
{reg, 8, "MMCREG"},
{&cmd, 1, "MMCCMD"},
{chrcmd, 8, "CHRCMD"},
{&prg0, 1, "PRG0"},
{&prg1, 1, "PRG1"},
{&brk, 1, "BRK"},
{&mirr, 1, "MIRR"},
{&IRQReload, 1, "IRQR"},
{&IRQCount, 1, "IRQC"},
{&IRQLatch, 1, "IRQL"},
{&IRQa, 1, "IRQA"},
{0}
};
static void Sync(void)
{
// if(brk&2)
// {
// setprg16(0x8000,~0);
// setprg16(0xC000,~0);
// }
// else
{
setprg8(0x8000,prg0);
setprg8(0xA000,prg1);
}
int i;
for(i=0; i<8; i++)
setchr1(i<<10,chrcmd[i]);
setmirror(mirr^1);
}
static void Sync2(void)
{
setprg8(0x8000,reg[6]&0x3F);
setprg8(0xA000,reg[7]&0x3F);
setchr2(0x0000,reg[0]>>1);
setchr2(0x8000,reg[1]>>1);
setchr1(0x1000,reg[2]);
setchr1(0x1400,reg[3]);
setchr1(0x1800,reg[4]);
setchr1(0x1C00,reg[5]);
setmirror(mirr^1);
}
static DECLFW(UNLSL1632CMDWrite)
{
FCEU_printf("bs %04x %02x\n",A,V);
// if((A&0xA131)==0xA131) brk=V;
if((A&0xA131)==0xA131) brk=V;
if(brk==2)
{
switch(A&0xE001)
{
case 0x8000: cmd=V&7; break;
case 0x8001: reg[cmd]=V; Sync(); break;
case 0xA000: mirr=V&1; break;
case 0xC000: IRQLatch=V; break;
case 0xC001: IRQReload=1; break;
case 0xE000: X6502_IRQEnd(FCEU_IQEXT); IRQa=0; break;
case 0xE001: IRQa=1; break;
}
Sync2();
}
else
{
switch(A&0xF003)
{
case 0x8000: prg0=V; break;
case 0xA000: prg1=V; break;
case 0x9000: mirr=V&1; break;
case 0xB000: chrcmd[0]=(chrcmd[0]&0xF0)|(V&0x0F); break;
case 0xB001: chrcmd[0]=(chrcmd[0]&0x0F)|(V<<4); break;
case 0xB002: chrcmd[1]=(chrcmd[1]&0xF0)|(V&0x0F); break;
case 0xB003: chrcmd[1]=(chrcmd[1]&0x0F)|(V<<4); break;
case 0xC000: chrcmd[2]=(chrcmd[2]&0xF0)|(V&0x0F); break;
case 0xC001: chrcmd[2]=(chrcmd[2]&0x0F)|(V<<4); break;
case 0xC002: chrcmd[3]=(chrcmd[3]&0xF0)|(V&0x0F); break;
case 0xC003: chrcmd[3]=(chrcmd[3]&0x0F)|(V<<4); break;
case 0xD000: chrcmd[4]=(chrcmd[4]&0xF0)|(V&0x0F); break;
case 0xD001: chrcmd[4]=(chrcmd[4]&0x0F)|(V<<4); break;
case 0xD002: chrcmd[5]=(chrcmd[5]&0xF0)|(V&0x0F); break;
case 0xD003: chrcmd[5]=(chrcmd[5]&0x0F)|(V<<4); break;
case 0xE000: chrcmd[6]=(chrcmd[6]&0xF0)|(V&0x0F); break;
case 0xE001: chrcmd[6]=(chrcmd[6]&0x0F)|(V<<4); break;
case 0xE002: chrcmd[7]=(chrcmd[7]&0xF0)|(V&0x0F); break;
case 0xE003: chrcmd[7]=(chrcmd[7]&0x0F)|(V<<4); break;
}
Sync();
}
}
static void UNLSL1632IRQHook(void)
{
int count = IRQCount;
if((scanline==128)&&IRQa)X6502_IRQBegin(FCEU_IQEXT);
if(!count || IRQReload)
{
IRQCount = IRQLatch;
IRQReload = 0;
}
else
IRQCount--;
if(!IRQCount)
{
if(IRQa)
{
X6502_IRQBegin(FCEU_IQEXT);
}
}
}
static void StateRestore(int version)
{
Sync();
}
static void UNLSL1632Power(void)
{
setprg16(0xC000,~0);
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x8000,0xFFFF,UNLSL1632CMDWrite);
}
void UNLSL1632_Init(CartInfo *info)
{
info->Power=UNLSL1632Power;
GameHBIRQHook2=UNLSL1632IRQHook;
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,71 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
#include "mmc3.h"
static uint8 m_perm[8] = {0, 1, 0, 3, 0, 5, 6, 7};
static void UNLSonicPW(uint32 A, uint8 V)
{
if(EXPREGS[0]&0x80)
{
uint8 bank=EXPREGS[0]&0x1F;
if(EXPREGS[0]&0x20)
setprg32(0x8000,bank>>2);
else
{
setprg16(0x8000,bank);
setprg16(0xC000,bank);
}
}
else
setprg8(A,V&0x3F);
}
static DECLFW(UNLSonicWrite8000)
{
if(V&0x80)
MMC3_CMDWrite(A,V);
else
MMC3_CMDWrite(A,m_perm[V&7]);
}
static DECLFW(UNLSonicWriteLo)
{
EXPREGS[0]=V;
FixMMC3PRG(MMC3_cmd);
}
static void UNLSonicPower(void)
{
EXPREGS[0]=EXPREGS[1]=EXPREGS[2]=0;
GenMMC3Power();
SetWriteHandler(0x5000,0x5FFF,UNLSonicWriteLo);
// SetWriteHandler(0x8000,0x8000,UNLSonicWrite8000);
}
void UNLSonic_Init(CartInfo *info)
{
GenMMC3_Init(info, 256, 256, 0, 0);
pwrap=UNLSonicPW;
info->Power=UNLSonicPower;
AddExState(EXPREGS, 3, 0, "EXPR");
}

View File

@ -1,79 +0,0 @@
#include "mapinc.h"
static uint8 mode;
static uint8 DRegs[4];
static SFORMAT StateRegs[]=
{
{DRegs, 4, "DREG"},
{0}
};
static void Sync(void)
{
int base, bank;
base = ((DRegs[0]^DRegs[1])&0x10)<<1;
bank = (DRegs[2]^DRegs[3])&0x1f;
if(DRegs[1]&0x08)
{
bank &= 0xfe;
if(mode==0)
{
setprg16(0x8000,base+bank+1);
setprg16(0xC000,base+bank+0);
}
else
{
setprg16(0x8000,base+bank+0);
setprg16(0xC000,base+bank+1);
}
}
else
{
if(DRegs[1]&0x04)
{
setprg16(0x8000,0x1f);
setprg16(0xC000,base+bank);
}
else
{
setprg16(0x8000,base+bank);
if(mode==0)
setprg16(0xC000,0x20);
else
setprg16(0xC000,0x07);
}
}
}
static DECLFW(Mapper167_write)
{
DRegs[(A>>13)&0x03]=V;
Sync();
}
static void StateRestore(int version)
{
Sync();
}
void Mapper166_init(void)
{
mode=1;
DRegs[0]=DRegs[1]=DRegs[2]=DRegs[3]=0;
Sync();
SetWriteHandler(0x8000,0xFFFF,Mapper167_write);
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}
void Mapper167_init(void)
{
mode=0;
DRegs[0]=DRegs[1]=DRegs[2]=DRegs[3]=0;
Sync();
SetWriteHandler(0x8000,0xFFFF,Mapper167_write);
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,99 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
#include "mmc3.h"
static uint8 *CHRRAM = NULL;
static int masko8[8]={63,31,15,1,3,0,0,0};
static void Super24PW(uint32 A, uint8 V)
{
uint32 NV=V&masko8[EXPREGS[0]&7];
NV|=(EXPREGS[1]<<1);
setprg8r((NV>>6)&0xF,A,NV);
}
static void Super24CW(uint32 A, uint8 V)
{
if(EXPREGS[0]&0x20)
setchr1r(0x10,A,V);
else
{
uint32 NV=V|(EXPREGS[2]<<3);
setchr1r((NV>>9)&0xF,A,NV);
}
}
static DECLFW(Super24Write)
{
switch(A)
{
case 0x5FF0: EXPREGS[0]=V;
FixMMC3PRG(MMC3_cmd);
FixMMC3CHR(MMC3_cmd);
break;
case 0x5FF1: EXPREGS[1]=V;
FixMMC3PRG(MMC3_cmd);
break;
case 0x5FF2: EXPREGS[2]=V;
FixMMC3CHR(MMC3_cmd);
break;
}
}
static void Super24Power(void)
{
EXPREGS[0]=0x24;
EXPREGS[1]=159;
EXPREGS[2]=0;
GenMMC3Power();
SetWriteHandler(0x5000,0x7FFF,Super24Write);
SetReadHandler(0x8000,0xFFFF,CartBR);
}
static void Super24Reset(void)
{
EXPREGS[0]=0x24;
EXPREGS[1]=159;
EXPREGS[2]=0;
MMC3RegReset();
}
static void Super24Close(void)
{
if(CHRRAM)
FCEU_gfree(CHRRAM);
CHRRAM = NULL;
}
void Super24_Init(CartInfo *info)
{
GenMMC3_Init(info, 128, 256, 0, 0);
info->Power=Super24Power;
info->Reset=Super24Reset;
info->Close=Super24Close;
cwrap=Super24CW;
pwrap=Super24PW;
CHRRAM=(uint8*)FCEU_gmalloc(8192);
SetupCartCHRMapping(0x10, CHRRAM, 8192, 1);
AddExState(CHRRAM, 8192, 0, "CHRR");
AddExState(EXPREGS, 3, 0, "BIG2");
}

View File

@ -1,74 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static uint8 cmd0, cmd1;
static void DoSuper(void)
{
setprg8r((cmd0&0xC)>>2,0x6000,((cmd0&0x3)<<4)|0xF);
if(cmd0&0x10)
{
setprg16r((cmd0&0xC)>>2,0x8000,((cmd0&0x3)<<3)|(cmd1&7));
setprg16r((cmd0&0xC)>>2,0xc000,((cmd0&0x3)<<3)|7);
}
else
setprg32r(4,0x8000,0);
setmirror(((cmd0&0x20)>>5)^1);
}
static DECLFW(SuperWrite)
{
if(!(cmd0&0x10))
{
cmd0=V;
DoSuper();
}
}
static DECLFW(SuperHi)
{
cmd1=V;
DoSuper();
}
static void SuperReset(void)
{
SetWriteHandler(0x6000,0x7FFF,SuperWrite);
SetWriteHandler(0x8000,0xFFFF,SuperHi);
SetReadHandler(0x6000,0xFFFF,CartBR);
cmd0=cmd1=0;
setprg32r(4,0x8000,0);
setchr8(0);
}
static void SuperRestore(int version)
{
DoSuper();
}
void Supervision16_Init(CartInfo *info)
{
AddExState(&cmd0, 1, 0,"L1");
AddExState(&cmd1, 1, 0,"L2");
info->Power=SuperReset;
GameStateRestore=SuperRestore;
}

View File

@ -1,83 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static uint16 addrreg;
static uint8 datareg;
static uint8 busy;
static SFORMAT StateRegs[]=
{
{&addrreg, 2, "ADDRREG"},
{&datareg, 1, "DATAREG"},
{&busy, 1, "BUSY"},
{0}
};
static void Sync(void)
{
setprg16(0x8000,(datareg&7)|((addrreg&0x60)>>2)|((addrreg&0x100)>>3));
setprg16(0xC000,7|((addrreg&0x60)>>2)|((addrreg&0x100)>>3));
setmirror(((addrreg&2)>>1)^1);
}
static DECLFW(BMCT262Write)
{
if(busy||(A==0x8000))
datareg=V;
else
{
addrreg=A;
busy=1;
}
Sync();
}
static void BMCT262Power(void)
{
setchr8(0);
SetWriteHandler(0x8000,0xFFFF,BMCT262Write);
SetReadHandler(0x8000,0xFFFF,CartBR);
busy=0;
addrreg=0;
datareg=0;
Sync();
}
static void BMCT262Reset(void)
{
busy=0;
addrreg=0;
datareg=0;
Sync();
}
static void BMCT262Restore(int version)
{
Sync();
}
void BMCT262_Init(CartInfo *info)
{
info->Power=BMCT262Power;
info->Reset=BMCT262Reset;
GameStateRestore=BMCT262Restore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,198 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static uint8 cmd,mir,rmode,IRQmode;
static uint8 DRegs[11];
static uint8 IRQCount,IRQa,IRQLatch;
static SFORMAT Rambo_StateRegs[]={
{&cmd, 1, "CMD"},
{&mir, 1, "MIR"},
{&rmode, 1, "RMOD"},
{&IRQmode, 1, "IRQM"},
{&IRQCount, 1, "IRQC"},
{&IRQa, 1, "IRQA"},
{&IRQLatch, 1, "IRQL"},
{DRegs, 11, "DREG"},
{0}
};
static void FP_FASTAPASS(2) (*setchr1wrap)(unsigned int A, unsigned int V);
static int nomirror;
static void FP_FASTAPASS(1) RAMBO1_IRQHook(int a)
{
static int smallcount;
if(!IRQmode) return;
smallcount+=a;
while(smallcount>=4)
{
smallcount-=4;
IRQCount--;
if(IRQCount==0xFF)
if(IRQa) X6502_IRQBegin(FCEU_IQEXT);
}
}
static void RAMBO1_hb(void)
{
if(IRQmode) return;
if(scanline==240) return; /* hmm. Maybe that should be an mmc3-only call in fce.c. */
rmode=0;
IRQCount--;
if(IRQCount==0xFF)
{
if(IRQa)
{
rmode = 1;
X6502_IRQBegin(FCEU_IQEXT);
}
}
}
static void Synco(void)
{
int x;
if(cmd&0x20)
{
setchr1wrap(0x0000,DRegs[0]);
setchr1wrap(0x0800,DRegs[1]);
setchr1wrap(0x0400,DRegs[8]);
setchr1wrap(0x0c00,DRegs[9]);
}
else
{
setchr1wrap(0x0000,(DRegs[0]&0xFE));
setchr1wrap(0x0400,(DRegs[0]&0xFE)|1);
setchr1wrap(0x0800,(DRegs[1]&0xFE));
setchr1wrap(0x0C00,(DRegs[1]&0xFE)|1);
}
for(x=0;x<4;x++)
setchr1wrap(0x1000+x*0x400,DRegs[2+x]);
setprg8(0x8000,DRegs[6]);
setprg8(0xA000,DRegs[7]);
setprg8(0xC000,DRegs[10]);
}
static DECLFW(RAMBO1_write)
{
switch(A&0xF001)
{
case 0xa000: mir=V&1;
if(!nomirror)
setmirror(mir^1);
break;
case 0x8000: cmd = V;
break;
case 0x8001: if((cmd&0xF)<10)
DRegs[cmd&0xF]=V;
else if((cmd&0xF)==0xF)
DRegs[10]=V;
Synco();
break;
case 0xc000: IRQLatch=V;
if(rmode==1)
IRQCount=IRQLatch;
break;
case 0xc001: rmode=1;
IRQCount=IRQLatch;
IRQmode=V&1;
break;
case 0xE000: IRQa=0;
X6502_IRQEnd(FCEU_IQEXT);
if(rmode==1)
IRQCount=IRQLatch;
break;
case 0xE001: IRQa=1;
if(rmode==1)
IRQCount=IRQLatch;
break;
}
}
static void RAMBO1_Restore(int version)
{
Synco();
if(!nomirror)
setmirror(mir^1);
}
static void RAMBO1_init(void)
{
int x;
for(x=0;x<11;x++)
DRegs[x]=~0;
cmd=mir=0;
if(!nomirror)
setmirror(1);
Synco();
GameHBIRQHook=RAMBO1_hb;
MapIRQHook=RAMBO1_IRQHook;
GameStateRestore=RAMBO1_Restore;
SetWriteHandler(0x8000,0xffff,RAMBO1_write);
AddExState(Rambo_StateRegs, ~0, 0, 0);
}
static void FP_FASTAPASS(2) CHRWrap(unsigned int A, unsigned int V)
{
setchr1(A,V);
}
void Mapper64_init(void)
{
setchr1wrap=CHRWrap;
nomirror=0;
RAMBO1_init();
}
static int MirCache[8];
static unsigned int PPUCHRBus;
static void FP_FASTAPASS(2) MirWrap(unsigned int A, unsigned int V)
{
MirCache[A>>10]=(V>>7)&1;
if(PPUCHRBus==(A>>10))
setmirror(MI_0+((V>>7)&1));
setchr1(A,V);
}
static void FP_FASTAPASS(1) MirrorFear(uint32 A)
{
A&=0x1FFF;
A>>=10;
PPUCHRBus=A;
setmirror(MI_0+MirCache[A]);
}
void Mapper158_init(void)
{
setchr1wrap=MirWrap;
PPU_hook=MirrorFear;
nomirror=1;
RAMBO1_init();
}

View File

@ -236,7 +236,7 @@ void FCEU_LoadGameCheats(FILE *override)
char *neo=&tbuf[4+2+2+1+1+1]; char *neo=&tbuf[4+2+2+1+1+1];
if(sscanf(tbuf,"%04x%*[:]%02x%*[:]%02x",&addr,&val,&compare)!=3) if(sscanf(tbuf,"%04x%*[:]%02x%*[:]%02x",&addr,&val,&compare)!=3)
continue; continue;
namebuf=malloc(strlen(neo)+1); namebuf=(char *)malloc(strlen(neo)+1);
strcpy(namebuf,neo); strcpy(namebuf,neo);
} }
else else
@ -244,11 +244,11 @@ void FCEU_LoadGameCheats(FILE *override)
char *neo=&tbuf[4+2+1+1]; char *neo=&tbuf[4+2+1+1];
if(sscanf(tbuf,"%04x%*[:]%02x",&addr,&val)!=2) if(sscanf(tbuf,"%04x%*[:]%02x",&addr,&val)!=2)
continue; continue;
namebuf=malloc(strlen(neo)+1); namebuf=(char *)malloc(strlen(neo)+1);
strcpy(namebuf,neo); strcpy(namebuf,neo);
} }
for(x=0;x<strlen(namebuf);x++) for(x=0;x<(int)strlen(namebuf);x++)
{ {
if(namebuf[x]==10 || namebuf[x]==13) if(namebuf[x]==10 || namebuf[x]==13)
{ {

View File

@ -180,7 +180,7 @@ static OPS optable[NUMOPS]=
uint16 FCEUI_Disassemble(void *XA, uint16 a, char *stringo) uint16 FCEUI_Disassemble(void *XA, uint16 a, char *stringo)
{ {
X6502 *X=XA; X6502 *X=(X6502*)XA;
uint8 buf; uint8 buf;
unsigned int arg; unsigned int arg;
int32 info; int32 info;

View File

@ -268,7 +268,7 @@ uint8 FCEUI_VSUniGetDIPs(void);
void FCEUI_VSUniSetDIP(int w, int state); void FCEUI_VSUniSetDIP(int w, int state);
void FCEUI_VSUniCoin(void); void FCEUI_VSUniCoin(void);
int FCEUI_FDSInsert(void); void FCEUI_FDSInsert(void); //mbg merge 7/17/06 changed to void fn(void) to make it an EMUCMDFN
//int FCEUI_FDSEject(void); //int FCEUI_FDSEject(void);
void FCEUI_FDSSelect(void); void FCEUI_FDSSelect(void);

View File

@ -11,7 +11,7 @@
#define DIRECTSOUND_VERSION 0x0700 #define DIRECTSOUND_VERSION 0x0700
#define DIRECTDRAW_VERSION 0x0700 #define DIRECTDRAW_VERSION 0x0700
#define DIRECTINPUT_VERSION 0x700 #define DIRECTINPUT_VERSION 0x700
#define FCEUDEF_DEBUGGER //#define FCEUDEF_DEBUGGER //mbg merge 7/17/06 removing conditional compiles
#include "../../types.h" #include "../../types.h"
#include "../../general.h" #include "../../general.h"
#include "../../driver.h" #include "../../driver.h"

View File

@ -28,7 +28,7 @@
#undef LPCWAVEFORMATEX #undef LPCWAVEFORMATEX
#include <dsound.h> #include <dsound.h>
#include <dinput.h> #include <dinput.h>
#include <dir.h> //#include <dir.h> //mbg merge 7/17/06 removed
#include <commctrl.h> #include <commctrl.h>
#include <shlobj.h> // For directories configuration dialog. #include <shlobj.h> // For directories configuration dialog.
#undef uint8 #undef uint8
@ -187,11 +187,12 @@ static int soundquality=0;
extern int autoHoldKey, autoHoldClearKey; extern int autoHoldKey, autoHoldClearKey;
extern int frame_display, input_display; extern int frame_display, input_display;
static unsigned int srendline,erendline; //mbg merge 7/17/06 why did these have to be unsigned
static unsigned int srendlinen=8; static int srendline,erendline;
static unsigned int erendlinen=231; static int srendlinen=8;
static unsigned int srendlinep=0; static int erendlinen=231;
static unsigned int erendlinep=239; static int srendlinep=0;
static int erendlinep=239;
static unsigned int totallines; static unsigned int totallines;

9
fceu.c
View File

@ -250,9 +250,10 @@ char lastLoadedGameName [2048] = {0,}; // hack for movie WRAM clearing on record
FCEUGI *FCEUI_LoadGame(const char *name, int OverwriteVidMode) FCEUGI *FCEUI_LoadGame(const char *name, int OverwriteVidMode)
{ {
#ifdef WIN32 //mbg merge 7/17/07 - why is this here
StopSound(); //#ifdef WIN32
#endif // StopSound();
//#endif
FCEUFILE *fp; FCEUFILE *fp;
char *ipsfn; char *ipsfn;
@ -262,7 +263,7 @@ FCEUGI *FCEUI_LoadGame(const char *name, int OverwriteVidMode)
RewindStatus[0] = RewindStatus[1] = 0; RewindStatus[0] = RewindStatus[1] = 0;
RewindStatus[2] = RewindStatus[3] = 0; RewindStatus[2] = RewindStatus[3] = 0;
FCEUGameInfo = malloc(sizeof(FCEUGI)); FCEUGameInfo = (FCEUGI*)malloc(sizeof(FCEUGI));
memset(FCEUGameInfo, 0, sizeof(FCEUGI)); memset(FCEUGameInfo, 0, sizeof(FCEUGI));
FCEUGameInfo->soundchan = 0; FCEUGameInfo->soundchan = 0;

2
fceu.h
View File

@ -102,7 +102,7 @@ extern uint8 Exit;
extern uint8 pale; extern uint8 pale;
extern uint8 vsdip; extern uint8 vsdip;
#define FCEUDEF_DEBUGGER //#define FCEUDEF_DEBUGGER //mbg merge 7/17/06 - cleaning out conditional compiles
#define JOY_A 1 #define JOY_A 1
#define JOY_B 2 #define JOY_B 2

4
fds.c
View File

@ -74,7 +74,7 @@ static uint8 *diskdatao[8]={0,0,0,0,0,0,0,0};
static uint8 *diskdata[8]={0,0,0,0,0,0,0,0}; static uint8 *diskdata[8]={0,0,0,0,0,0,0,0};
static unsigned int TotalSides; static int TotalSides; //mbg merge 7/17/06 - unsignedectomy
static uint8 DiskWritten=0; /* Set to 1 if disk was written to. */ static uint8 DiskWritten=0; /* Set to 1 if disk was written to. */
static uint8 writeskip; static uint8 writeskip;
static uint32 DiskPtr; static uint32 DiskPtr;
@ -532,7 +532,7 @@ static void RenderSound(void)
static void RenderSoundHQ(void) static void RenderSoundHQ(void)
{ {
int32 x; uint32 x; //mbg merge 7/17/06 - made this unsigned
if(!(SPSG[0x9]&0x80)) if(!(SPSG[0x9]&0x80))
for(x=FBC;x<SOUNDTS;x++) for(x=FBC;x<SOUNDTS;x++)

10
file.c
View File

@ -21,7 +21,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> //#include <unistd.h> //mbg merge 7/17/06 - removed
#include <zlib.h> #include <zlib.h>
#include "unzip.h" #include "unzip.h"
@ -289,7 +289,7 @@ FCEUFILE * FCEU_fopen(const char *path, const char *ipsfn, char *mode, char *ext
fd = dup(fileno( (FILE *)t)); fd = dup(fileno( (FILE *)t));
fclose(t); fclose((FILE*)t); //mbg merge 7/17/06 - cast to FILE*
lseek(fd, 0, SEEK_SET); lseek(fd, 0, SEEK_SET);
@ -420,7 +420,7 @@ int FCEU_fseek(FCEUFILE *fp, long offset, int whence)
switch(whence) switch(whence)
{ {
case SEEK_SET:if(offset>=wz->size) case SEEK_SET:if(offset>=(long)wz->size) //mbg merge 7/17/06 - added cast to long
return(-1); return(-1);
wz->location=offset;break; wz->location=offset;break;
case SEEK_CUR:if(offset+wz->location>wz->size) case SEEK_CUR:if(offset+wz->location>wz->size)
@ -460,12 +460,12 @@ void FCEU_rewind(FCEUFILE *fp)
} }
else else
/* Rewind */ /* Rewind */
fseek(fp->fp,0,SEEK_SET); fseek((FILE*)fp->fp,0,SEEK_SET); //mbg merge 7/17/06 - added cast to FILE*
} }
int FCEU_read16le(uint16 *val, FCEUFILE *fp) int FCEU_read16le(uint16 *val, FCEUFILE *fp)
{ {
uint8 t[2]; uint8 t[4]; //mbg merge 7/17/06 - changed size from 2 to 4 to avoid dangerous problem with uint32* poking
if(fp->type>=1) if(fp->type>=1)
{ {

View File

@ -25,7 +25,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> //#include <unistd.h> //mbg merge 7/17/06 - removed
#include "types.h" #include "types.h"
#include "fceu.h" #include "fceu.h"
@ -74,7 +74,7 @@ static int asprintf(char **strp, const char *fmt, ...)
int ret; int ret;
va_start(ap,fmt); va_start(ap,fmt);
if(!(*strp=malloc(2048))) if(!(*strp=(char*)malloc(2048))) //mbg merge 7/17/06 cast to char*
return(0); return(0);
ret=vsnprintf(*strp,2048,fmt,ap); ret=vsnprintf(*strp,2048,fmt,ap);
va_end(ap); va_end(ap);

34
input.c
View File

@ -434,19 +434,26 @@ SFORMAT FCEUCTRL_STATEINFO[]={
{ 0 } { 0 }
}; };
void FCEU_DoSimpleCommand(int cmd) void FCEU_DoSimpleCommand(int cmd)
{ {
switch(cmd) switch(cmd)
{ {
case FCEUNPCMD_FDSINSERT: FCEU_FDSInsert();break; case FCEUNPCMD_FDSINSERT: FCEU_FDSInsert();break;
case FCEUNPCMD_FDSSELECT: FCEU_FDSSelect();break; case FCEUNPCMD_FDSSELECT: FCEU_FDSSelect();break;
// case FCEUNPCMD_FDSEJECT: FCEU_FDSEject();break; // case FCEUNPCMD_FDSEJECT: FCEU_FDSEject();break;
case FCEUNPCMD_VSUNICOIN: FCEU_VSUniCoin(); break; case FCEUNPCMD_VSUNICOIN: FCEU_VSUniCoin(); break;
case FCEUNPCMD_VSUNIDIP0 ... (FCEUNPCMD_VSUNIDIP0 + 7): FCEU_VSUniToggleDIP(cmd - FCEUNPCMD_VSUNIDIP0);break; case FCEUNPCMD_VSUNIDIP0: //mbg merge 7/17/06 removed case range syntax
case FCEUNPCMD_POWER: PowerNES();break; case FCEUNPCMD_VSUNIDIP0+1:
case FCEUNPCMD_RESET: ResetNES();break; case FCEUNPCMD_VSUNIDIP0+2:
} case FCEUNPCMD_VSUNIDIP0+3:
case FCEUNPCMD_VSUNIDIP0+4:
case FCEUNPCMD_VSUNIDIP0+5:
case FCEUNPCMD_VSUNIDIP0+6:
case FCEUNPCMD_VSUNIDIP0+7:
FCEU_VSUniToggleDIP(cmd - FCEUNPCMD_VSUNIDIP0);break;
case FCEUNPCMD_POWER: PowerNES();break;
case FCEUNPCMD_RESET: ResetNES();break;
}
} }
void FCEU_QSimpleCommand(int cmd) void FCEU_QSimpleCommand(int cmd)
@ -466,10 +473,11 @@ void FCEUI_FDSSelect(void)
FCEU_QSimpleCommand(FCEUNPCMD_FDSSELECT); FCEU_QSimpleCommand(FCEUNPCMD_FDSSELECT);
} }
int FCEUI_FDSInsert(void) //mbg merge 7/17/06 changed to void fn(void) to make it an EMUCMDFN
void FCEUI_FDSInsert(void)
{ {
FCEU_QSimpleCommand(FCEUNPCMD_FDSINSERT); FCEU_QSimpleCommand(FCEUNPCMD_FDSINSERT);
return(1); //return(1);
} }
/* /*

View File

@ -1,64 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
/* I'm getting the feeling this is another "jam two different bank
switching hardwares into one mapper".
*/
/* HES 4-in-1 */
DECLFW(Mapper113_write)
{
ROM_BANK32((V>>3)&7);
VROM_BANK8(((V>>3)&8)|(V&7));
//printf("$%04x:$%02x\n",A,V);
}
/* Deathbots */
DECLFW(Mapper113_writeh)
{
//printf("$%04x:$%02x\n",A,V);
// ROM_BANK32(V&0x7);
//VROM_BANK8((V>>4)&0x7);
switch(A) {
case 0x8008:
case 0x8009:
ROM_BANK32(V>>3);
VROM_BANK8(((V>>3)&0x08)+(V&0x07) );
break;
case 0x8E66:
case 0x8E67:
VROM_BANK8( (V&0x07)?0:1 );
break;
case 0xE00A:
MIRROR_SET2( 2 );
break;
}
}
void Mapper113_init(void)
{
ROM_BANK32(0);
SetWriteHandler(0x4020,0x7fff,Mapper113_write);
SetWriteHandler(0x8000,0xffff,Mapper113_writeh);
}

View File

@ -1,73 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2003 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static void Sync(void)
{
int x;
setmirror(((mapbyte1[0]>>6)&1)^1);
switch(mapbyte1[1]&0x3)
{
case 0x0:
for(x=0;x<4;x++)
setprg8(0x8000+x*8192,(((mapbyte1[0]&0x7F)<<1)+x)^(mapbyte1[0]>>7));
break;
case 0x2:
for(x=0;x<4;x++)
setprg8(0x8000+x*8192,((mapbyte1[0]&0x7F)<<1)+(mapbyte1[0]>>7));
break;
case 0x1:
case 0x3:
for(x=0;x<4;x++)
{
unsigned int b;
b=mapbyte1[0]&0x7F;
if(x>=2 && !(mapbyte1[1]&0x2))
b=0x7F;
setprg8(0x8000+x*8192,(x&1)+((b<<1)^(mapbyte1[0]>>7)));
}
break;
}
}
static DECLFW(Mapper15_write)
{
mapbyte1[0]=V;
mapbyte1[1]=A&3;
Sync();
}
static void StateRestore(int version)
{
Sync();
}
void Mapper15_init(void)
{
mapbyte1[0]=mapbyte1[1]=0;
Sync();
GameStateRestore=StateRestore;
SetWriteHandler(0x8000,0xFFFF,Mapper15_write);
}

View File

@ -1,41 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
DECLFW(Mapper151_write)
{
switch(A&0xF000)
{
case 0x8000:ROM_BANK8(0x8000,V);break;
case 0xA000:ROM_BANK8(0xA000,V);break;
case 0xC000:ROM_BANK8(0xC000,V);break;
case 0xe000:VROM_BANK4(0x0000,V);break;
case 0xf000:VROM_BANK4(0x1000,V);break;
}
}
void Mapper151_init(void)
{
SetWriteHandler(0x8000,0xffff,Mapper151_write);
}

View File

@ -1,303 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 1998 BERO
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static void FP_FASTAPASS(1) BandaiIRQHook(int a)
{
if(IRQa)
{
IRQCount-=a;
if(IRQCount<0)
{
X6502_IRQBegin(FCEU_IQEXT);
//printf("IRQ: %d, %d\n",scanline,timestamp);
IRQa=0;
IRQCount=0xFFFF;
}
}
}
static DECLFW(Mapper16_write)
{
A&=0xF;
if(A<=0x7)
VROM_BANK1(A<<10,V);
else if(A==0x8)
ROM_BANK16(0x8000,V);
else switch(A) {
case 0x9: switch(V&3) {
case 0x00:MIRROR_SET2(1);break;
case 0x01:MIRROR_SET2(0);break;
case 0x02:onemir(0);break;
case 0x03:onemir(1);break;
}
break;
case 0xA:X6502_IRQEnd(FCEU_IQEXT);
IRQa=V&1;
IRQCount=IRQLatch;
break;
case 0xB:IRQLatch&=0xFF00; IRQLatch|=V;
break;
case 0xC:IRQLatch&=0xFF; IRQLatch|=V<<8;
break;
case 0xD: break;/* Serial EEPROM control port */
}
}
// Famicom jump 2:
// 0-7: Lower bit of data selects which 256KB PRG block is in use.
// This seems to be a hack on the developers' part, so I'll make emulation
// of it a hack(I think the current PRG block would depend on whatever the
// lowest bit of the CHR bank switching register that corresponds to the
// last CHR address read).
static void PRGO(void)
{
uint32 base=(mapbyte1[0]&1)<<4;
ROM_BANK16(0x8000,(mapbyte2[0]&0xF)|base);
ROM_BANK16(0xC000,base|0xF);
}
static DECLFW(Mapper153_write)
{
A&=0xF;
if(A<=0x7)
{
mapbyte1[A&7]=V;
PRGO();
}
else if(A==0x8)
{
mapbyte2[0]=V;
PRGO();
}
else switch(A) {
case 0x9: switch(V&3) {
case 0x00:MIRROR_SET2(1);break;
case 0x01:MIRROR_SET2(0);break;
case 0x02:onemir(0);break;
case 0x03:onemir(1);break;
}
break;
case 0xA:X6502_IRQEnd(FCEU_IQEXT);
IRQa=V&1;
IRQCount=IRQLatch;
break;
case 0xB:IRQLatch&=0xFF00;
IRQLatch|=V;
break;
case 0xC:IRQLatch&=0xFF;
IRQLatch|=V<<8;
break;
}
}
void Mapper16_init(void)
{
MapIRQHook=BandaiIRQHook;
SetWriteHandler(0x6000,0xFFFF,Mapper16_write);
}
void Mapper153_init(void)
{
MapIRQHook=BandaiIRQHook;
SetWriteHandler(0x8000,0xFFFF,Mapper153_write);
/* This mapper/board seems to have WRAM at $6000-$7FFF, so I'll let the
main ines code take care of that memory region. */
}
static uint8 BarcodeData[256];
static int BarcodeReadPos;
static int BarcodeCycleCount;
static uint32 BarcodeOut;
int FCEUI_DatachSet(const uint8 *rcode)
{
int prefix_parity_type[10][6] = {
{0,0,0,0,0,0}, {0,0,1,0,1,1}, {0,0,1,1,0,1}, {0,0,1,1,1,0},
{0,1,0,0,1,1}, {0,1,1,0,0,1}, {0,1,1,1,0,0}, {0,1,0,1,0,1},
{0,1,0,1,1,0}, {0,1,1,0,1,0}
};
int data_left_odd[10][7] = {
{0,0,0,1,1,0,1}, {0,0,1,1,0,0,1}, {0,0,1,0,0,1,1}, {0,1,1,1,1,0,1},
{0,1,0,0,0,1,1}, {0,1,1,0,0,0,1}, {0,1,0,1,1,1,1}, {0,1,1,1,0,1,1},
{0,1,1,0,1,1,1}, {0,0,0,1,0,1,1}
};
int data_left_even[10][7] = {
{0,1,0,0,1,1,1}, {0,1,1,0,0,1,1}, {0,0,1,1,0,1,1}, {0,1,0,0,0,0,1},
{0,0,1,1,1,0,1}, {0,1,1,1,0,0,1}, {0,0,0,0,1,0,1}, {0,0,1,0,0,0,1},
{0,0,0,1,0,0,1}, {0,0,1,0,1,1,1}
};
int data_right[10][7] = {
{1,1,1,0,0,1,0}, {1,1,0,0,1,1,0}, {1,1,0,1,1,0,0}, {1,0,0,0,0,1,0},
{1,0,1,1,1,0,0}, {1,0,0,1,1,1,0}, {1,0,1,0,0,0,0}, {1,0,0,0,1,0,0},
{1,0,0,1,0,0,0}, {1,1,1,0,1,0,0}
};
uint8 code[13+1];
uint32 tmp_p=0;
int i, j;
int len;
for(i=len=0;i<13;i++)
{
if(!rcode[i]) break;
if((code[i]=rcode[i]-'0') > 9)
return(0);
len++;
}
if(len!=13 && len!=12 && len!=8 && len!=7) return(0);
#define BS(x) BarcodeData[tmp_p]=x;tmp_p++
for(j=0;j<32;j++)
{
BS(0x00);
}
/* Left guard bars */
BS(1); BS(0); BS(1);
if(len==13 || len==12)
{
uint32 csum;
for(i=0;i<6;i++)
if(prefix_parity_type[code[0]][i])
{
for(j=0;j<7;j++)
{
BS(data_left_even[code[i+1]][j]);
}
}
else
for(j=0;j<7;j++)
{
BS(data_left_odd[code[i+1]][j]);
}
/* Center guard bars */
BS(0); BS(1); BS(0); BS(1); BS(0);
for(i=7;i<12;i++)
for(j=0;j<7;j++)
{
BS(data_right[code[i]][j]);
}
csum=0;
for(i=0;i<12;i++) csum+=code[i]*((i&1)?3:1);
csum=(10-(csum%10))%10;
//printf("%d\n",csum);
for(j=0;j<7;j++)
{
BS(data_right[csum][j]);
}
}
else if(len==8 || len==7)
{
uint32 csum=0;
for(i=0;i<7;i++) csum+=(i&1)?code[i]:(code[i]*3);
csum=(10-(csum%10))%10;
for(i=0;i<4;i++)
for(j=0;j<7;j++)
{
BS(data_left_odd[code[i]][j]);
}
/* Center guard bars */
BS(0); BS(1); BS(0); BS(1); BS(0);
for(i=4;i<7;i++)
for(j=0;j<7;j++)
{
BS(data_right[code[i]][j]);
}
for(j=0;j<7;j++)
{ BS(data_right[csum][j]);}
}
/* Right guard bars */
BS(1); BS(0); BS(1);
for(j=0;j<32;j++)
{
BS(0x00);
}
BS(0xFF);
#undef BS
BarcodeReadPos=0;
BarcodeOut=0x8;
BarcodeCycleCount=0;
return(1);
}
static void FP_FASTAPASS(1) BarcodeIRQHook(int a)
{
BandaiIRQHook(a);
BarcodeCycleCount+=a;
if(BarcodeCycleCount >= 1000)
{
BarcodeCycleCount -= 1000;
if(BarcodeData[BarcodeReadPos]==0xFF)
{
BarcodeOut=0;
}
else
{
BarcodeOut=(BarcodeData[BarcodeReadPos]^1)<<3;
BarcodeReadPos++;
}
}
}
static DECLFR(Mapper157_read)
{
uint8 ret;
ret=BarcodeOut;
return(ret);
}
void Mapper157_init(void)
{
FCEUGameInfo->cspecial = SIS_DATACH;
MapIRQHook=BarcodeIRQHook;
SetWriteHandler(0x6000,0xFFFF,Mapper16_write);
SetReadHandler(0x6000,0x7FFF,Mapper157_read);
BarcodeData[0]=0xFF;
BarcodeReadPos=0;
BarcodeOut=0;
BarcodeCycleCount=0;
}

View File

@ -1,73 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static void FP_FASTAPASS(1) FFEIRQHook(int a)
{
if(IRQa)
{
IRQCount+=a;
if(IRQCount>=0x10000)
{
X6502_IRQBegin(FCEU_IQEXT);
IRQa=0;
IRQCount=0;
}
}
}
DECLFW(Mapper17_write)
{
switch(A){
default:
break;
case 0x42FE:
onemir((V>>4)&1);
break;
case 0x42FF:
MIRROR_SET((V>>4)&1);
break;
case 0x4501:IRQa=0;X6502_IRQEnd(FCEU_IQEXT);break;
case 0x4502:IRQCount&=0xFF00;IRQCount|=V;break;
case 0x4503:IRQCount&=0x00FF;IRQCount|=V<<8;IRQa=1;break;
case 0x4504: ROM_BANK8(0x8000,V);break;
case 0x4505: ROM_BANK8(0xA000,V);break;
case 0x4506: ROM_BANK8(0xC000,V);break;
case 0x4507: ROM_BANK8(0xE000,V);break;
case 0x4510: VROM_BANK1(0x0000,V);break;
case 0x4511: VROM_BANK1(0x0400,V);break;
case 0x4512: VROM_BANK1(0x0800,V);break;
case 0x4513: VROM_BANK1(0x0C00,V);break;
case 0x4514: VROM_BANK1(0x1000,V);break;
case 0x4515: VROM_BANK1(0x1400,V);break;
case 0x4516: VROM_BANK1(0x1800,V);break;
case 0x4517: VROM_BANK1(0x1C00,V);break;
}
}
void Mapper17_init(void)
{
MapIRQHook=FFEIRQHook;
SetWriteHandler(0x4020,0x5fff,Mapper17_write);
}

View File

@ -1,80 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
#define K4buf mapbyte2
#define K4buf2 mapbyte3
void FP_FASTAPASS(1) JalecoIRQHook(int a)
{
if(IRQa && IRQCount)
{
IRQCount-=a;
if(IRQCount<=0)
{
X6502_IRQBegin(FCEU_IQEXT);
IRQCount=0;
IRQa=0;
}
}
}
DECLFW(Mapper18_write)
{
A&=0xF003;
if(A>=0x8000 && A<=0x9001)
{
int x=((A>>1)&1)|((A-0x8000)>>11);
K4buf2[x]&=(0xF0)>>((A&1)<<2);
K4buf2[x]|=(V&0xF)<<((A&1)<<2);
ROM_BANK8(0x8000+(x<<13),K4buf2[x]);
}
else if(A>=0xa000 && A<=0xd003)
{
int x=((A>>1)&1)|((A-0xA000)>>11);
K4buf[x]&=(0xF0)>>((A&1)<<2);
K4buf[x]|=(V&0xF)<<((A&1)<<2);
VROM_BANK1(x<<10,K4buf[x]);
}
else switch(A)
{
case 0xe000:IRQLatch&=0xFFF0;IRQLatch|=(V&0x0f);break;
case 0xe001:IRQLatch&=0xFF0F;IRQLatch|=(V&0x0f)<<4;break;
case 0xe002:IRQLatch&=0xF0FF;IRQLatch|=(V&0x0f)<<8;break;
case 0xe003:IRQLatch&=0x0FFF;IRQLatch|=(V&0x0f)<<12;break;
case 0xf000:IRQCount=IRQLatch;
break;
case 0xf001:IRQa=V&1;
X6502_IRQEnd(FCEU_IQEXT);
break;
case 0xf002:MIRROR_SET2(V&1);
if(V&2) onemir(0);
break;
}
}
void Mapper18_init(void)
{
SetWriteHandler(0x8000,0xffff,Mapper18_write);
MapIRQHook=JalecoIRQHook;
}

View File

@ -1,14 +0,0 @@
#include "mapinc.h"
DECLFW(Mapper180_write)
{
ROM_BANK16(0xC000,V);
}
void Mapper180_init(void)
{
SetWriteHandler(0x8000,0xffff,Mapper180_write);
}

View File

View File

@ -1,15 +0,0 @@
#include "mapinc.h"
DECLFW(Mapper184_write)
{
VROM_BANK4(0x0000,V);
VROM_BANK4(0x1000,(V>>4));
}
void Mapper184_init(void)
{
SetWriteHandler(0x6000,0xffff,Mapper184_write);
}

View File

@ -1,20 +0,0 @@
#include "mapinc.h"
static DECLFW(m193w)
{
//printf("$%04x:$%02x\n",A,V);
switch(A&3)
{
case 0:VROM_BANK4(0x0000,V>>2);break;
case 1:VROM_BANK2(0x1000,V>>1);break;
case 2:VROM_BANK2(0x1800,V>>1);break;
case 3:ROM_BANK8(0x8000,V);break;
}
}
void Mapper193_init(void)
{
ROM_BANK32(~0);
SetWriteHandler(0x4018,0x7fff,m193w);
SetReadHandler(0x4018,0x7fff,0);
}

View File

@ -1,36 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static DECLFW(Mapper200_write)
{
// FCEU_printf("%04x, %02x\n",A,V);
ROM_BANK16(0x8000,A&0x07);
ROM_BANK16(0xC000,A&0x07);
VROM_BANK8(A&0x07);
MIRROR_SET((A&0x08)>>3);
}
void Mapper200_init(void)
{
SetWriteHandler(0x8000,0xffff,Mapper200_write);
}

View File

@ -1,44 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static DECLFW(Mapper201_write)
{
// FCEU_printf("%04x, %02x\n",A,V);
if(A&0x08)
{
ROM_BANK32(A&0x03);
VROM_BANK8(A&0x03);
}
else
{
ROM_BANK32(0);
VROM_BANK8(0);
}
}
void Mapper201_init(void)
{
ROM_BANK32(0);
VROM_BANK8(0);
SetWriteHandler(0x8000,0xffff,Mapper201_write);
}

View File

@ -1,39 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2003 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static DECLFW(Mapper202_write)
{
int tmp=(A>>1)&0x7;
MIRROR_SET(A&1);
ROM_BANK16(0x8000,tmp);
ROM_BANK16(0xc000,tmp+(((tmp&0x6)==0x6)?1:0));
VROM_BANK8(tmp);
}
void Mapper202_init(void)
{
ROM_BANK16(0x8000,0);
ROM_BANK16(0xc000,0);
VROM_BANK8(0);
SetWriteHandler(0x8000,0xFFFF,Mapper202_write);
}

View File

@ -1,36 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2003 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static DECLFW(Mapper203_write)
{
ROM_BANK16(0x8000,(V>>2)&3);
ROM_BANK16(0xc000,(V>>2)&3);
VROM_BANK8(V&3);
}
void Mapper203_init(void)
{
ROM_BANK16(0x8000,0);
ROM_BANK16(0xc000,0);
VROM_BANK8(0);
SetWriteHandler(0x8000,0xFFFF,Mapper203_write);
}

View File

@ -1,38 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static DECLFW(Mapper204_write)
{
int tmp2=A&0x6;
int tmp1=tmp2+((tmp2==0x6)?0:(A&1));
MIRROR_SET((A>>4)&1);
ROM_BANK16(0x8000,tmp1);
ROM_BANK16(0xc000,tmp2+((tmp2==0x6)?1:(A&1)));
VROM_BANK8(tmp1);
}
void Mapper204_init(void)
{
ROM_BANK32(~0);
VROM_BANK8(~0);
SetWriteHandler(0x8000,0xFFFF,Mapper204_write);
}

View File

@ -1,106 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
#define K4buf mapbyte2
#define K4IRQ mapbyte1[1]
#define K4sel mapbyte1[0]
static int acount=0;
DECLFW(Mapper21_write)
{
A|=((A>>5)&0xF);
if((A&0xF000)==0xA000)
ROM_BANK8(0xA000,V);
else if((A&0xF000)==0x8000)
{
if(K4sel&2)
ROM_BANK8(0xC000,V);
else
ROM_BANK8(0x8000,V);
}
else if(A>=0xb000 && A<=0xefff)
{
A&=0xF006;
{
int x=((A>>2)&1)|((A-0xB000)>>11);
K4buf[x]&=(0xF0)>>((A&2)<<1);
K4buf[x]|=(V&0xF)<<((A&2)<<1);
VROM_BANK1(x<<10,K4buf[x]);
}
}
else switch(A&0xF006)
{
case 0x9000:
switch(V&0x3)
{
case 0:MIRROR_SET(0);break;
case 1:MIRROR_SET(1);break;
case 2:onemir(0);break;
case 3:onemir(1);break;
}
break;
case 0x9006:
case 0x9004:
case 0x9002:if((K4sel&2)!=(V&2))
{
uint8 swa;
swa=PRGBankList[0];
ROM_BANK8(0x8000,PRGBankList[2]);
ROM_BANK8(0xc000,swa);
}
K4sel=V;
break;
case 0xf000:IRQLatch&=0xF0;IRQLatch|=V&0xF;break;
case 0xf002:IRQLatch&=0x0F;IRQLatch|=V<<4;break;
case 0xf004:IRQCount=IRQLatch;acount=0;
IRQa=V&2;K4IRQ=V&1;
X6502_IRQEnd(FCEU_IQEXT);
break;
case 0xf006:IRQa=K4IRQ;X6502_IRQEnd(FCEU_IQEXT);break;
}
}
static void FP_FASTAPASS(1) KonamiIRQHook(int a)
{
#define LCYCS ((227*2)+1)
//#define LCYCS 341
if(IRQa)
{
// acount+=a*3;
acount+=a*4;
if(acount>=LCYCS)
{
doagainbub:acount-=LCYCS;IRQCount++;
if(IRQCount&0x100) {X6502_IRQBegin(FCEU_IQEXT);IRQCount=IRQLatch;}
if(acount>=LCYCS) goto doagainbub;
}
}
}
void Mapper21_init(void)
{
SetWriteHandler(0x8000,0xffff,Mapper21_write);
MapIRQHook=KonamiIRQHook;
}

View File

@ -1,23 +0,0 @@
#include "mapinc.h"
static DECLFW(Mapper212_write)
{
if((A&0x4000)==0x4000)
{
ROM_BANK32((A&6)>>1);
}
else
{
ROM_BANK16(0x8000,A&7);
ROM_BANK16(0xc000,A&7);
}
VROM_BANK8(A&7);
MIRROR_SET((A>>3)&1);
}
void Mapper212_init(void)
{
ROM_BANK32(~0);
VROM_BANK8(~0);
SetWriteHandler(0x8000,0xFFFF,Mapper212_write);
}

View File

@ -1,14 +0,0 @@
#include "mapinc.h"
static DECLFW(Mapper213_write)
{
ROM_BANK32((A>>1)&3);
VROM_BANK8((A>>3)&7);
}
void Mapper213_init(void)
{
ROM_BANK32(0);
VROM_BANK8(0);
SetWriteHandler(0x8000,0xFFFF,Mapper213_write);
}

View File

@ -1,17 +0,0 @@
#include "mapinc.h"
static DECLFW(Mapper214_write)
{
// FCEU_printf("%02x:%02x\n",A,V);
ROM_BANK16(0x8000,(A>>2)&3);
ROM_BANK16(0xC000,(A>>2)&3);
VROM_BANK8(A&3);
}
void Mapper214_init(void)
{
ROM_BANK16(0x8000,0);
ROM_BANK16(0xC000,0);
VROM_BANK8(0);
SetWriteHandler(0x8000,0xFFFF,Mapper214_write);
}

View File

@ -1,96 +0,0 @@
/*
#include "mapinc.h"
static uint8 cmdin;
static uint8 cmd;
static uint8 regs[8];
static uint8 master,chrm;
static void DoPRG215(void)
{
if(master&0x80)
{
setprg16(0x8000,master&0x1F);
setprg16(0xc000,master&0x1F);
}
else
{
setprg8(0x8000,regs[4]); 6
setprg8(0xA000,regs[6]); 7 0, 2, 5, 3, 6, 1, 7, 4
setprg8(0xC000,~1);
setprg8(0xE000,~0);
}
}
static void DoCHR215(void)
{
uint32 base=(cmd&0x80)<<5;
int orie=(chrm&0x4)<<6;
setchr2(0x0000^base,(orie|regs[0])>>1); 0
setchr2(0x0800^base,(orie|regs[5])>>1); 1
setchr1(0x1000,orie|regs[1]); 2
setchr1(0x1400,orie|regs[3]); 3
setchr1(0x1800,orie|regs[7]); 4
setchr1(0x1c00,orie|regs[2]); 5
}
static DECLFW(Write215_write)
{
switch(A&0xF001)
{
case 0xF001:IRQCount=V+2;break;
case 0xF000:X6502_IRQEnd(FCEU_IQEXT);break;
}
if(A==0x5000)
{
master=V;
DoPRG215();
// DoCHR215();
}
else if(A==0x5001)
{
chrm=V;
DoCHR215();
}
else
switch(A&0xE001)
{
case 0xC000:setmirror(((V|(V>>7))&1)^1);break;
case 0xa000:cmd=V;cmdin=1;DoCHR215();break;
case 0x8001:if(!cmdin) break;
regs[cmd&7]=V;
DoPRG215();
DoCHR215();
cmdin=0;
break;
}
}
static void hooko215(void)
{
if(IRQCount)
{
IRQCount--;
if(!IRQCount)
{
X6502_IRQBegin(FCEU_IQEXT);
}
}
}
void Mapper215_init(void)
{
int x;
for(x=0;x<8;x++) regs[x]=0;
master=chrm=cmd=cmdin=IRQCount=0;
GameHBIRQHook=hooko215;
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x5000,0xFFFF,Write215_write);
DoPRG215();
DoCHR215();
}
*/

View File

@ -1,96 +0,0 @@
/*
#include "mapinc.h"
static uint8 cmdin;
static uint8 cmd;
static uint8 regs[8];
static uint8 master,chrm;
static void DoPRG217(void)
{
if(master&0x80)
{
setprg16(0x8000,master&0x1F);
setprg16(0xc000,master&0x1F);
}
else
{
setprg8(0x8000,regs[1]);
setprg8(0xA000,regs[3]);
setprg8(0xC000,~1);
setprg8(0xE000,~0);
}
}
static void DoCHR217(void)
{
uint32 base=(cmd&0x80)<<5;
int orie=(chrm&0x4)<<6;
setchr2(0x0000^base,(orie|regs[0])>>1);
setchr2(0x0800^base,(orie|regs[7])>>1);
setchr1(0x1000,orie|regs[5]);
setchr1(0x1400,orie|regs[2]);
setchr1(0x1800,orie|regs[6]);
setchr1(0x1c00,orie|regs[4]);
}
static DECLFW(Write217_write)
{
// if(A==0x5000)
// {
// master=V;
// DoPRG217();
// }
// else if(A==0x5001)
// {
// chrm=V;
// DoCHR217();
// }
// else if(A==0x5007)
// {
// }
switch(A&0xE001)
{
case 0x4000:master=V;DoPRG217();break;
case 0x8000:IRQCount=V;break;
case 0xc001:break;
case 0xe000:X6502_IRQEnd(FCEU_IQEXT);break;
case 0xe001:break;
case 0xa001:setmirror((V&1)^1);break;
case 0x8001:cmd=V;cmdin=1;DoPRG217();DoCHR217();break;
case 0xa000:if(!cmdin) break;
regs[cmd&7]=V;
DoPRG217();
DoCHR217();
cmdin=0;
break;
}
}
static void hooko217(void)
{
if(IRQCount)
{
IRQCount--;
if(!IRQCount)
{
X6502_IRQBegin(FCEU_IQEXT);
}
}
}
void Mapper217_init(void)
{
int x;
for(x=0;x<8;x++) regs[x]=0;
master=chrm=cmd=cmdin=IRQCount=0;
GameHBIRQHook=hooko217;
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x5000,0xFFFF,Write217_write);
DoPRG217();
DoCHR217();
}
*/

View File

@ -1,63 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
#define K4buf mapbyte2
DECLFW(Mapper22_write)
{
if(A<=0xAFFF)
{
switch(A&0xF000)
{
case 0x8000:ROM_BANK8(0x8000,V);break;
case 0xa000:ROM_BANK8(0xA000,V);break;
case 0x9000:switch(V&3)
{
case 0x00:MIRROR_SET2(1);break;
case 0x01:MIRROR_SET2(0);break;
case 0x02:onemir(0);break;
case 0x03:onemir(1);break;
}
break;
}
}
else
{
A&=0xF003;
if(A>=0xb000 && A<=0xe003)
{
int x=(A&1)|((A-0xB000)>>11);
K4buf[x]&=(0xF0)>>((A&2)<<1);
K4buf[x]|=(V&0xF)<<((A&2)<<1);
VROM_BANK1(x<<10,K4buf[x]>>1);
}
}
}
void Mapper22_init(void)
{
SetWriteHandler(0x8000,0xffff,Mapper22_write);
}

View File

@ -1,87 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
#define reg1 mapbyte1[0]
#define reg2 mapbyte1[1]
#define reg3 mapbyte1[2]
#define reg4 mapbyte1[3]
DECLFR(A110in1read)
{
switch(A&0x3)
{
case 0:return reg1;break;
case 1:return reg2;break;
case 2:return reg3;break;
case 3:return reg4;break;
}
return 0xF;
}
DECLFW(A110in1regwr)
{
switch(A&0x3)
{
case 0:reg1=V&0xF;break;
case 1:reg2=V&0xF;break;
case 2:reg3=V&0xF;break;
case 3:reg4=V&0xF;break;
}
}
DECLFW(Mapper225_write)
{
int banks=0;
MIRROR_SET((A>>13)&1);
if(A&0x4000)
banks=1;
else
banks=0;
VROM_BANK8(((A&0x003f)+(banks<<6)));
if(A&0x1000)
{
if(A&0x40)
{
ROM_BANK16(0x8000,((((((A>>7)&0x1F)+(banks<<5)))<<1)+1));
ROM_BANK16(0xC000,((((((A>>7)&0x1F)+(banks<<5)))<<1)+1));
}
else
{
ROM_BANK16(0x8000,(((((A>>7)&0x1F)+(banks<<5)))<<1));
ROM_BANK16(0xC000,(((((A>>7)&0x1F)+(banks<<5)))<<1));
}
}
else
{
ROM_BANK32(((((A>>7)&0x1F)+(banks<<5))));
}
}
void Mapper225_init(void)
{
SetWriteHandler(0x8000,0xffff,Mapper225_write);
SetReadHandler(0x5800,0x5fff,A110in1read);
SetWriteHandler(0x5800,0x5fff,A110in1regwr);
}

View File

@ -1,105 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
#define rg mapbyte1
static void DoPRG(void)
{
int32 b=((rg[0]>>1)&0xF) | ((rg[0]>>3)&0x10) | ((rg[1]&1)<<5);
if(rg[0]&0x20) // 16 KB
{
ROM_BANK16(0x8000,(b<<1)|(rg[0]&1));
ROM_BANK16(0xC000,(b<<1)|(rg[0]&1));
}
else
ROM_BANK32(b);
}
static DECLFW(Mapper226_write)
{
rg[A&1]=V;
DoPRG();
if(A&1)
{
if(rg[1]&2)
PPUCHRRAM=0; // Write protected.
else
PPUCHRRAM=0xFF; // Not write protected.
}
else
MIRROR_SET2((rg[0]>>6)&1);
}
static void M26Reset(void)
{
rg[0]=rg[1]=0;
DoPRG();
PPUCHRRAM=0xFF;
MIRROR_SET2(0);
}
static void M26Restore(int version)
{
DoPRG();
if(rg[1]&2)
PPUCHRRAM=0; // Write protected.
else
PPUCHRRAM=0xFF; // Not write protected.
MIRROR_SET2((rg[0]>>6)&1);
}
void Mapper226_init(void)
{
SetWriteHandler(0x8000,0xffff,Mapper226_write);
MapperReset=M26Reset;
GameStateRestore=M26Restore;
M26Reset();
}
#ifdef OLD // What the heck is this??
DECLFW(Mapper226_write)
{
MIRROR_SET((A>>13)&1);
VROM_BANK8(A&0x7F);
if(A&0x1000)
{
if(A&0x40)
{
ROM_BANK16(0x8000,(((A>>7))<<1)+1);
ROM_BANK16(0xC000,(((A>>7))<<1)+1);
}
else
{
ROM_BANK16(0x8000,(((A>>7))<<1));
ROM_BANK16(0xC000,(((A>>7))<<1));
}
}
else
{
ROM_BANK32(A>>7);
}
}
void Mapper226_init(void)
{
SetWriteHandler(0x8000,0xffff,Mapper226_write);
}
#endif

View File

@ -1,79 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
#define rg mapbyte1
static void DoSync(uint32 A)
{
int32 p=((A>>3)&0xF) | ((A>>4)&0x10);
rg[0]=A;
rg[1]=A>>8;
MIRROR_SET((A>>1)&1);
if(A&1) //32 KB
{
ROM_BANK32(p);
}
else //16 KB
{
ROM_BANK16(0x8000,(p<<1)|((A&4)>>2));
ROM_BANK16(0xc000,(p<<1)|((A&4)>>2));
}
if(A&0x80)
{
PPUCHRRAM=0;
}
else
{
PPUCHRRAM=0xFF;
if(A&0x200)
ROM_BANK16(0xC000,(p<<1)|7);
else
ROM_BANK16(0xC000,(p<<1)&(~7));
}
}
static DECLFW(Mapper227_write)
{
rg[A&1]=V;
DoSync(A);
}
static void M227Reset(void)
{
rg[0]=rg[1]=0;
DoSync(0);
}
static void M227Restore(int version)
{
DoSync(rg[0]|(rg[1]<<8));
}
void Mapper227_init(void)
{
SetWriteHandler(0x6000,0xffff,Mapper227_write);
MapperReset=M227Reset;
GameStateRestore=M227Restore;
M227Reset();
}

View File

@ -1,53 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static DECLFW(Mapper228_write)
{
uint32 page,pagel,pageh;
MIRROR_SET((A>>13)&1);
page=(A>>7)&0x3F;
//printf("%04x\n",A);
if((page&0x30)==0x30)
page-=0x10;
pagel=pageh=(page<<1) + (((A>>6)&1)&((A>>5)&1));
pageh+=((A>>5)&1)^1;
ROM_BANK16(0x8000,pagel);
ROM_BANK16(0xC000,pageh);
VROM_BANK8( (V&0x3) | ((A&0xF)<<2) );
}
static void A52Reset(void)
{
Mapper228_write(0,0);
}
void Mapper228_init(void)
{
MapperReset=A52Reset;
A52Reset();
SetWriteHandler(0x8000,0xffff,Mapper228_write);
}

View File

@ -1,48 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
DECLFW(Mapper229_write)
{
if(A>=0x8000)
{
MIRROR_SET((A>>5)&1);
if(!(A&0x1e))
{
ROM_BANK32(0);
}
else
{
ROM_BANK16(0x8000,A&0x1f);
ROM_BANK16(0xC000,A&0x1f);
}
VROM_BANK8(A);
}
}
void Mapper229_init(void)
{
SetWriteHandler(0x8000,0xffff,Mapper229_write);
}

View File

@ -1,103 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
#define K4buf mapbyte2
#define K4IRQ mapbyte1[1]
#define K4sel mapbyte1[0]
static int acount=0;
static DECLFW(Mapper23_write)
{
if((A&0xF000)==0x8000)
{
if(K4sel&2)
ROM_BANK8(0xC000,V);
else
ROM_BANK8(0x8000,V);
}
else if((A&0xF000)==0xA000)
ROM_BANK8(0xA000,V);
else
{
A|=((A>>2)&0x3)|((A>>4)&0x3)|((A>>6)&0x3);
A&=0xF003;
if(A>=0xb000 && A<=0xe003)
{
int x=((A>>1)&1)|((A-0xB000)>>11);
K4buf[x]&=(0xF0)>>((A&1)<<2);
K4buf[x]|=(V&0xF)<<((A&1)<<2);
VROM_BANK1(x<<10,K4buf[x]);
}
else
switch(A)
{
case 0xf000:X6502_IRQEnd(FCEU_IQEXT);IRQLatch&=0xF0;IRQLatch|=V&0xF;break;
case 0xf001:X6502_IRQEnd(FCEU_IQEXT);IRQLatch&=0x0F;IRQLatch|=V<<4;break;
case 0xf002:X6502_IRQEnd(FCEU_IQEXT);acount=0;IRQCount=IRQLatch;IRQa=V&2;K4IRQ=V&1;break;
case 0xf003:X6502_IRQEnd(FCEU_IQEXT);IRQa=K4IRQ;break;
case 0x9001:
case 0x9002:
case 0x9003:
if((K4sel&2)!=(V&2))
{
uint8 swa;
swa=PRGBankList[0];
ROM_BANK8(0x8000,PRGBankList[2]);
ROM_BANK8(0xc000,swa);
}
K4sel=V;
break;
case 0x9000:
if(V!=0xFF)
switch(V&0x3)
{
case 0:MIRROR_SET(0);break;
case 1:MIRROR_SET(1);break;
case 2:onemir(0);break;
case 3:onemir(1);break;
}
break;
}
}
}
void FP_FASTAPASS(1) KonamiIRQHook2(int a)
{
#define LCYCS 341
if(IRQa)
{
acount+=a*3;
if(acount>=LCYCS)
{
doagainbub:acount-=LCYCS;IRQCount++;
if(IRQCount&0x100) {X6502_IRQBegin(FCEU_IQEXT);IRQCount=IRQLatch;}
if(acount>=LCYCS) goto doagainbub;
}
}
}
void Mapper23_init(void)
{
SetWriteHandler(0x8000,0xffff,Mapper23_write);
MapIRQHook=KonamiIRQHook2;
}

View File

@ -1,62 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
#define rom_sw mapbyte1[0]
void Mapper230_Reset(void)
{
rom_sw ^= 1; //1 - rom_sw;
if( rom_sw ) {
ROM_BANK16(0x8000,0);
ROM_BANK16(0xc000,7);
} else {
ROM_BANK16(0x8000,8);
ROM_BANK16(0xc000,39);
}
MIRROR_SET2(1);
}
static DECLFW(Mapper230_write)
{
if( rom_sw ) {
ROM_BANK16( 0x8000, V&0x07 );
} else {
if( V & 0x20 ) {
ROM_BANK16( 0x8000, (V&0x1F)+8 );
ROM_BANK16( 0xc000, (V&0x1F)+8 );
} else {
ROM_BANK32( ((V&0x1E) >> 1) + 4 );
}
MIRROR_SET2( ((V & 0x40) >> 6) );
}
}
void Mapper230_init(void)
{
ROM_BANK16(0x8000,0);
ROM_BANK16(0xc000,7);
SetWriteHandler(0x8000, 0xffff, Mapper230_write);
MapperReset = Mapper230_Reset;
rom_sw = 1;
}

View File

@ -1,41 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2003 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static DECLFW(Mapper231_write)
{
if(A&0x20)
ROM_BANK32((A>>1)&0xF);
else
{
ROM_BANK16(0x8000,(A&0x1E));
ROM_BANK16(0xc000,(A&0x1E));
}
MIRROR_SET((A>>7)&1);
}
void Mapper231_init(void)
{
ROM_BANK16(0x8000,0);
ROM_BANK16(0xc000,0);
SetWriteHandler(0x8000,0xffff,Mapper231_write);
}

View File

@ -1,50 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static void DoIt(void)
{
ROM_BANK16(0x8000,(mapbyte1[1]&3) | ((mapbyte1[0]&0x18)>>1));
ROM_BANK16(0xc000,3|(((mapbyte1[0])&0x18)>>1));
}
DECLFW(Mapper232_write)
{
if(A<=0x9FFF)
mapbyte1[0]=V;
else
mapbyte1[1]=V;
DoIt();
}
static void QuattroReset(void)
{
mapbyte1[0]=0x18;
DoIt();
}
void Mapper232_init(void)
{
SetWriteHandler(0x6000,0xffff,Mapper232_write);
MapperReset=QuattroReset;
QuattroReset();
}

View File

@ -1,107 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
#define r1 mapbyte1[0]
#define r2 mapbyte1[1]
static void DoBS(void)
{
if(r1&0x40)
{
ROM_BANK32((r1&0xE)|(r2&1));
VROM_BANK8( ((r1&0xE)<<2) | ((r2>>4)&7) );
}
else
{
ROM_BANK32(r1&0xF);
VROM_BANK8( ((r1&0xF)<<2) | ((r2>>4)&3) );
}
}
static void R1Set(uint8 V)
{
if(r1) return;
r1=V;
MIRROR_SET(V>>7);
DoBS();
}
static void R2Set(uint8 V)
{
r2=V;
DoBS();
}
DECLFW(R1W)
{
R1Set(V);
}
DECLFR(R1R)
{
uint8 r=CartBR(A);
R1Set(r);
return r;
}
DECLFW(R2W)
{
R2Set(V);
}
DECLFR(R2R)
{
uint8 r=CartBR(A);
R2Set(r);
return r;
}
static void M15Restore(int version)
{
DoBS();
MIRROR_SET(r1>>7);
}
static void M15Reset(void)
{
r1=r2=0;
DoBS();
MIRROR_SET(0);
}
void Mapper234_init(void)
{
SetWriteHandler(0xff80,0xff9f,R1W);
SetReadHandler(0xff80,0xff9f,R1R);
SetWriteHandler(0xffe8,0xfff7,R2W);
SetReadHandler(0xffe8,0xfff7,R2R);
SetReadHandler(0x6000,0x7FFF,0);
SetWriteHandler(0x6000,0x7FFF,0);
M15Reset();
GameStateRestore=M15Restore;
MapperReset=M15Reset;
}

View File

@ -1,39 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
DECLFW(Mapper240_write)
{
if(A<0x8000)
{
ROM_BANK32(V>>4);
VROM_BANK8(V&0xF);
}
}
void Mapper240_init(void)
{
SetWriteHandler(0x4020,0x5fff,Mapper240_write);
SetWriteHandler(0x8000,0xffff,Mapper240_write);
}

View File

@ -1,27 +0,0 @@
#include "mapinc.h"
static DECLFW(M241wr)
{
// FCEU_printf("Wr: $%04x:$%02x, $%04x\n",A,V,X.PC);
if(A<0x8000)
{
// printf("$%04x:$%02x, $%04x\n",A,V,X.PC);
}
else
ROM_BANK32(V);
}
static DECLFR(M241rd)
{
//DumpMem("out",0x8000,0xffff);
//printf("Rd: $%04x, $%04x\n",A,X.PC);
return(0x50);
}
void Mapper241_init(void)
{
ROM_BANK32(0);
SetWriteHandler(0x5000,0x5fff,M241wr);
SetWriteHandler(0x8000,0xFFFF,M241wr);
SetReadHandler(0x4020,0x5fff,M241rd);
}

View File

@ -1,41 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
DECLFW(Mapper242_write)
{
ROM_BANK32((A>>3)&0xF);
switch(V&3)
{
case 0:MIRROR_SET(0);break;
case 1:MIRROR_SET(1);break;
case 2:onemir(0);break;
case 3:onemir(1);break;
}
}
void Mapper242_init(void)
{
ROM_BANK32(0);
SetWriteHandler(0x8000,0xffff,Mapper242_write);
}

View File

@ -1,38 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static DECLFW(Mapper244_write_1)
{
ROM_BANK32((A-0x8065)&0x03);
}
static DECLFW(Mapper244_write_2)
{
VROM_BANK8((A-0x80A5)&0x07);
}
void Mapper244_init(void)
{
ROM_BANK32(0);
SetWriteHandler(0x8065,0x80a4,Mapper244_write_1);
SetWriteHandler(0x80a5,0x80e4,Mapper244_write_2);
}

View File

@ -1,44 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
DECLFW(Mapper246_write)
{
switch(A&0xF007)
{
case 0x6000:ROM_BANK8(0x8000,V);break;
case 0x6001:ROM_BANK8(0xA000,V);break;
case 0x6002:ROM_BANK8(0xC000,V);break;
case 0x6003:ROM_BANK8(0xE000,V);break;
case 0x6004:VROM_BANK2(0x0000,V);break;
case 0x6005:VROM_BANK2(0x0800,V);break;
case 0x6006:VROM_BANK2(0x1000,V);break;
case 0x6007:VROM_BANK2(0x1800,V);break;
}
}
void Mapper246_init(void)
{
SetWriteHandler(0x4020,0x67ff,Mapper246_write);
SetWriteHandler(0x8000,0xffff,Mapper246_write);
}

View File

@ -1,369 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
static void (*sfun[3])(void);
#define vrctemp mapbyte1[0]
#define VPSG2 mapbyte3
#define VPSG mapbyte2
static void DoSQV1(void);
static void DoSQV2(void);
static void DoSawV(void);
static int swaparoo;
static int acount=0;
static void FP_FASTAPASS(1) KonamiIRQHook(int a)
{
#define LCYCS 341
// #define LCYCS ((227*2)+1)
if(IRQa)
{
acount+=a*3;
if(acount>=LCYCS)
{
doagainbub:acount-=LCYCS;IRQCount++;
if(IRQCount==0x100)
{
X6502_IRQBegin(FCEU_IQEXT);
IRQCount=IRQLatch;
}
if(acount>=LCYCS) goto doagainbub;
}
}
}
static DECLFW(VRC6SW)
{
A&=0xF003;
if(A>=0x9000 && A<=0x9002)
{
VPSG[A&3]=V;
if(sfun[0]) sfun[0]();
}
else if(A>=0xa000 && A<=0xa002)
{
VPSG[4|(A&3)]=V;
if(sfun[1]) sfun[1]();
}
else if(A>=0xb000 && A<=0xb002)
{
VPSG2[A&3]=V;
if(sfun[2]) sfun[2]();
}
}
static DECLFW(Mapper24_write)
{
if(swaparoo)
A=(A&0xFFFC)|((A>>1)&1)|((A<<1)&2);
if(A>=0x9000 && A<=0xb002)
{
VRC6SW(A,V);
return;
}
A&=0xF003;
// if(A>=0xF000) printf("%d, %d, $%04x:$%02x\n",scanline,timestamp,A,V);
switch(A&0xF003)
{
case 0x8000:ROM_BANK16(0x8000,V);break;
case 0xB003:
switch(V&0xF)
{
case 0x0:MIRROR_SET2(1);break;
case 0x4:MIRROR_SET2(0);break;
case 0x8:onemir(0);break;
case 0xC:onemir(1);break;
}
break;
case 0xC000:ROM_BANK8(0xC000,V);break;
case 0xD000:VROM_BANK1(0x0000,V);break;
case 0xD001:VROM_BANK1(0x0400,V);break;
case 0xD002:VROM_BANK1(0x0800,V);break;
case 0xD003:VROM_BANK1(0x0c00,V);break;
case 0xE000:VROM_BANK1(0x1000,V);break;
case 0xE001:VROM_BANK1(0x1400,V);break;
case 0xE002:VROM_BANK1(0x1800,V);break;
case 0xE003:VROM_BANK1(0x1c00,V);break;
case 0xF000:IRQLatch=V;
//acount=0;
break;
case 0xF001:IRQa=V&2;
vrctemp=V&1;
if(V&2)
{
IRQCount=IRQLatch;
acount=0;
}
X6502_IRQEnd(FCEU_IQEXT);
break;
case 0xf002:IRQa=vrctemp;
X6502_IRQEnd(FCEU_IQEXT);break;
case 0xF003:break;
}
}
static int32 CVBC[3];
static int32 vcount[3];
static int32 dcount[2];
static INLINE void DoSQV(int x)
{
int32 V;
int32 amp=(((VPSG[x<<2]&15)<<8)*6/8)>>4;
int32 start,end;
start=CVBC[x];
end=(SOUNDTS<<16)/soundtsinc;
if(end<=start) return;
CVBC[x]=end;
if(VPSG[(x<<2)|0x2]&0x80)
{
if(VPSG[x<<2]&0x80)
{
for(V=start;V<end;V++)
Wave[V>>4]+=amp;
}
else
{
int32 thresh=(VPSG[x<<2]>>4)&7;
int32 freq=((VPSG[(x<<2)|0x1]|((VPSG[(x<<2)|0x2]&15)<<8))+1)<<17;
for(V=start;V<end;V++)
{
if(dcount[x]>thresh) /* Greater than, not >=. Important. */
Wave[V>>4]+=amp;
vcount[x]-=nesincsize;
while(vcount[x]<=0) /* Should only be <0 in a few circumstances. */
{
vcount[x]+=freq;
dcount[x]=(dcount[x]+1)&15;
}
}
}
}
}
static void DoSQV1(void)
{
DoSQV(0);
}
static void DoSQV2(void)
{
DoSQV(1);
}
static void DoSawV(void)
{
int V;
int32 start,end;
start=CVBC[2];
end=(SOUNDTS<<16)/soundtsinc;
if(end<=start) return;
CVBC[2]=end;
if(VPSG2[2]&0x80)
{
static int32 saw1phaseacc=0;
uint32 freq3;
static uint8 b3=0;
static int32 phaseacc=0;
static uint32 duff=0;
freq3=(VPSG2[1]+((VPSG2[2]&15)<<8)+1);
for(V=start;V<end;V++)
{
saw1phaseacc-=nesincsize;
if(saw1phaseacc<=0)
{
int32 t;
rea:
t=freq3;
t<<=18;
saw1phaseacc+=t;
phaseacc+=VPSG2[0]&0x3f;
b3++;
if(b3==7)
{
b3=0;
phaseacc=0;
}
if(saw1phaseacc<=0)
goto rea;
duff=(((phaseacc>>3)&0x1f)<<4)*6/8;
}
Wave[V>>4]+=duff;
}
}
}
static INLINE void DoSQVHQ(int x)
{
int32 V;
int32 amp=((VPSG[x<<2]&15)<<8)*6/8;
if(VPSG[(x<<2)|0x2]&0x80)
{
if(VPSG[x<<2]&0x80)
{
for(V=CVBC[x];V<SOUNDTS;V++)
WaveHi[V]+=amp;
}
else
{
int32 thresh=(VPSG[x<<2]>>4)&7;
for(V=CVBC[x];V<SOUNDTS;V++)
{
if(dcount[x]>thresh) /* Greater than, not >=. Important. */
WaveHi[V]+=amp;
vcount[x]--;
if(vcount[x]<=0) /* Should only be <0 in a few circumstances. */
{
vcount[x]=(VPSG[(x<<2)|0x1]|((VPSG[(x<<2)|0x2]&15)<<8))+1;
dcount[x]=(dcount[x]+1)&15;
}
}
}
}
CVBC[x]=SOUNDTS;
}
static void DoSQV1HQ(void)
{
DoSQVHQ(0);
}
static void DoSQV2HQ(void)
{
DoSQVHQ(1);
}
static void DoSawVHQ(void)
{
static uint8 b3=0;
static int32 phaseacc=0;
int32 V;
if(VPSG2[2]&0x80)
{
for(V=CVBC[2];V<SOUNDTS;V++)
{
WaveHi[V]+=(((phaseacc>>3)&0x1f)<<8)*6/8;
vcount[2]--;
if(vcount[2]<=0)
{
vcount[2]=(VPSG2[1]+((VPSG2[2]&15)<<8)+1)<<1;
phaseacc+=VPSG2[0]&0x3f;
b3++;
if(b3==7)
{
b3=0;
phaseacc=0;
}
}
}
}
CVBC[2]=SOUNDTS;
}
void VRC6Sound(int Count)
{
int x;
DoSQV1();
DoSQV2();
DoSawV();
for(x=0;x<3;x++)
CVBC[x]=Count;
}
void VRC6SoundHQ(void)
{
DoSQV1HQ();
DoSQV2HQ();
DoSawVHQ();
}
void VRC6SyncHQ(int32 ts)
{
int x;
for(x=0;x<3;x++) CVBC[x]=ts;
}
static void VRC6_ESI(void)
{
GameExpSound.RChange=VRC6_ESI;
GameExpSound.Fill=VRC6Sound;
GameExpSound.HiFill=VRC6SoundHQ;
GameExpSound.HiSync=VRC6SyncHQ;
memset(CVBC,0,sizeof(CVBC));
memset(vcount,0,sizeof(vcount));
memset(dcount,0,sizeof(dcount));
if(FSettings.SndRate)
{
if(FSettings.soundq>=1)
{
sfun[0]=DoSQV1HQ;
sfun[1]=DoSQV2HQ;
sfun[2]=DoSawVHQ;
}
else
{
sfun[0]=DoSQV1;
sfun[1]=DoSQV2;
sfun[2]=DoSawV;
}
}
else
memset(sfun,0,sizeof(sfun));
}
void Mapper24_init(void)
{
SetWriteHandler(0x8000,0xffff,Mapper24_write);
VRC6_ESI();
MapIRQHook=KonamiIRQHook;
swaparoo=0;
}
void Mapper26_init(void)
{
SetWriteHandler(0x8000,0xffff,Mapper24_write);
VRC6_ESI();
MapIRQHook=KonamiIRQHook;
swaparoo=1;
}
void NSFVRC6_Init(void)
{
VRC6_ESI();
SetWriteHandler(0x8000,0xbfff,VRC6SW);
}

View File

@ -1,100 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
#define K4buf mapbyte2
#define K4IRQ mapbyte1[1]
#define K4sel mapbyte1[0]
static int acount=0;
static DECLFW(Mapper25_write)
{
A=(A&0xF003)|((A&0xC)>>2);
if((A&0xF000)==0xA000)
ROM_BANK8(0xA000,V);
else if(A>=0xB000 && A<=0xEFFF)
{
int x=(A&1)|((A-0xB000)>>11);
K4buf[x]&=(0xF0)>>((A&2)<<1);
K4buf[x]|=(V&0xF)<<((A&2)<<1);
VROM_BANK1(x<<10,K4buf[x]);
}
else if((A&0xF000)==0x8000)
{
if(K4sel&2)
ROM_BANK8(0xC000,V);
else
ROM_BANK8(0x8000,V);
}
else switch(A)
{
case 0x9000:switch(V&0x3)
{
case 0:MIRROR_SET(0);break;
case 1:MIRROR_SET(1);break;
case 2:onemir(0);break;
case 3:onemir(1);break;
}
break;
case 0x9001:if((K4sel&2)!=(V&2))
{
uint8 swa;
swa=PRGBankList[0];
ROM_BANK8(0x8000,PRGBankList[2]);
ROM_BANK8(0xc000,swa);
}
K4sel=V;
break;
case 0xf000:IRQLatch&=0xF0;IRQLatch|=V&0xF;break;
case 0xf002:IRQLatch&=0x0F;IRQLatch|=V<<4;break;
case 0xf001:IRQCount=IRQLatch;IRQa=V&2;K4IRQ=V&1;acount=0;X6502_IRQEnd(FCEU_IQEXT);break;
case 0xf003:IRQa=K4IRQ;X6502_IRQEnd(FCEU_IQEXT);break;
}
}
static void FP_FASTAPASS(1) KonamiIRQHook(int a)
{
// #define LCYCS ((227*2))
#define LCYCS 341
if(IRQa)
{
acount+=a*3;
// acount+=a*4;
if(acount>=LCYCS)
{
doagainbub:acount-=LCYCS;IRQCount++;
if(IRQCount&0x100)
{//acount=0;
X6502_IRQBegin(FCEU_IQEXT);IRQCount=IRQLatch;
}
if(acount>=LCYCS) goto doagainbub;
}
}
}
void Mapper25_init(void)
{
SetWriteHandler(0x8000,0xffff,Mapper25_write);
MapIRQHook=KonamiIRQHook;
}

Some files were not shown because too many files have changed in this diff Show More