merge mapper code from FCEUX
authornotaz <notasas@gmail.com>
Sat, 29 Sep 2012 23:11:57 +0000 (02:11 +0300)
committernotaz <notasas@gmail.com>
Sun, 30 Sep 2012 15:09:26 +0000 (18:09 +0300)
seems to be work by CaH4e3 and others

178 files changed:
boards/01-222.c [new file with mode: 0644]
boards/103.c [new file with mode: 0644]
boards/106.c [new file with mode: 0644]
boards/108.c [moved from boards/bmcgk192.c with 57% similarity]
boards/112.c
boards/116.c [new file with mode: 0644]
boards/117.c
boards/120.c [new file with mode: 0644]
boards/121.c [new file with mode: 0644]
boards/15.c [new file with mode: 0644]
boards/164.c
boards/175.c [new file with mode: 0644]
boards/176.c [new file with mode: 0644]
boards/177.c [new file with mode: 0644]
boards/178.c [new file with mode: 0644]
boards/179.c [new file with mode: 0644]
boards/183.c
boards/185.c
boards/186.c
boards/187.c
boards/189.c
boards/199.c [new file with mode: 0644]
boards/208.c
boards/222.c
boards/23.c [new file with mode: 0644]
boards/235.c
boards/253.c [new file with mode: 0644]
boards/3d-block.c [new file with mode: 0644]
boards/411120-c.c [new file with mode: 0644]
boards/43.c [new file with mode: 0644]
boards/57.c
boards/603-5052.c [moved from boards/cc21.c with 54% similarity]
boards/68.c [new file with mode: 0644]
boards/8157.c
boards/8237.c
boards/830118C.c [new file with mode: 0644]
boards/88.c
boards/90.c
boards/95.c
boards/Makefile
boards/__dummy_mapper.c
boards/a9711.c [moved from boards/sonic5.c with 51% similarity]
boards/a9746.c [new file with mode: 0644]
boards/addrlatch.c [new file with mode: 0644]
boards/ax5705.c [new file with mode: 0644]
boards/bandai.c [new file with mode: 0644]
boards/bmc13in1jy110.c
boards/bmc42in1r.c
boards/bmc64in1nr.c
boards/bmc70in1.c
boards/bonza.c
boards/bs-5.c [new file with mode: 0644]
boards/datalatch.c
boards/deirom.c
boards/dream.c
boards/edu2000.c [new file with mode: 0644]
boards/fk23c.c
boards/ghostbusters63in1.c [new file with mode: 0644]
boards/gs-2004.c [new file with mode: 0644]
boards/gs-2013.c [new file with mode: 0644]
boards/h2288.c
boards/karaoke.c
boards/kof97.c
boards/konami-qtai.c
boards/ks7032.c [new file with mode: 0644]
boards/malee.c
boards/mapinc.h
boards/mmc1.c
boards/mmc3.c
boards/mmc3.h
boards/mmc5.c
boards/n-c22m.c [new file with mode: 0644]
boards/n106.c
boards/n625092.c [new file with mode: 0644]
boards/novel.c
boards/onebus.c [new file with mode: 0644]
boards/sachen.c
boards/sc-127.c [new file with mode: 0644]
boards/sheroes.c
boards/sl1632.c
boards/smb2j.c [new file with mode: 0644]
boards/subor.c
boards/super24.c
boards/supervision.c
boards/t-227-1.c [new file with mode: 0644]
boards/t-262.c
boards/tengen.c
boards/tf-1201.c [new file with mode: 0644]
driver.h
fce.c
fce.h
file.h
git.h
ines-correct.h
ines.c
ines.h
mappers/113.c [deleted file]
mappers/15.c [deleted file]
mappers/151.c
mappers/156.c [new file with mode: 0644]
mappers/16.c
mappers/17.c
mappers/18.c
mappers/180.c [deleted file]
mappers/183.c [deleted file]
mappers/184.c [deleted file]
mappers/200.c [deleted file]
mappers/201.c
mappers/202.c
mappers/203.c
mappers/204.c
mappers/21.c
mappers/212.c
mappers/213.c
mappers/214.c
mappers/217.c
mappers/22.c
mappers/225.c
mappers/226.c [deleted file]
mappers/227.c
mappers/228.c
mappers/229.c
mappers/23.c [deleted file]
mappers/230.c
mappers/231.c
mappers/232.c
mappers/234.c
mappers/240.c [deleted file]
mappers/242.c
mappers/244.c
mappers/246.c
mappers/24and26.c
mappers/25.c
mappers/255.c
mappers/27.c
mappers/32.c
mappers/33.c
mappers/40.c
mappers/41.c
mappers/42.c
mappers/43.c [deleted file]
mappers/46.c
mappers/50.c
mappers/51.c
mappers/59.c
mappers/6.c
mappers/60.c
mappers/61.c
mappers/62.c
mappers/65.c
mappers/67.c
mappers/68.c [deleted file]
mappers/69.c
mappers/71.c
mappers/72.c
mappers/73.c
mappers/75.c
mappers/76.c
mappers/77.c
mappers/79.c
mappers/8.c
mappers/80.c
mappers/82.c
mappers/83.c
mappers/85.c
mappers/86.c
mappers/89.c
mappers/91.c
mappers/92.c
mappers/97.c
mappers/99.c
mappers/Makefile
mappers/mmc2and4.c
mappers/simple.c
svga.h
types.h
unif.c
unif.h

diff --git a/boards/01-222.c b/boards/01-222.c
new file mode 100644 (file)
index 0000000..c0e7320
--- /dev/null
@@ -0,0 +1,103 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2006 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ * TXC mappers\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg[4], cmd, is172, is173;\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {reg, 4, "REGS"},\r
+  {&cmd, 1, "CMD"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setprg32(0x8000,(reg[2]>>2)&1);\r
+  if(is172)\r
+    setchr8((((cmd^reg[2])>>3)&2)|(((cmd^reg[2])>>5)&1)); // 1991 DU MA Racing probably CHR bank sequence is WRONG, so it is possible to\r
+                                                          // rearrange CHR banks for normal UNIF board and mapper 172 is unneccessary\r
+  else\r
+    setchr8(reg[2]&3);\r
+}\r
+\r
+static DECLFW(UNL22211WriteLo)\r
+{\r
+//  FCEU_printf("bs %04x %02x\n",A,V);\r
+  reg[A&3]=V;\r
+}\r
+\r
+static DECLFW(UNL22211WriteHi)\r
+{\r
+//  FCEU_printf("bs %04x %02x\n",A,V);\r
+  cmd=V;\r
+  Sync();\r
+}\r
+\r
+static DECLFR(UNL22211ReadLo)\r
+{\r
+    return (reg[1]^reg[2])|(is173?0x01:0x40);\r
+//  if(reg[3])\r
+//    return reg[2];\r
+//  else\r
+//    return X.DB;\r
+}\r
+\r
+static void UNL22211Power(void)\r
+{\r
+  Sync();\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetReadHandler(0x4100,0x4100,UNL22211ReadLo);\r
+  SetWriteHandler(0x4100,0x4103,UNL22211WriteLo);\r
+  SetWriteHandler(0x8000,0xFFFF,UNL22211WriteHi);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void UNL22211_Init(CartInfo *info)\r
+{\r
+  is172=0;\r
+  is173=0;\r
+  info->Power=UNL22211Power;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
+\r
+void Mapper172_Init(CartInfo *info)\r
+{\r
+  is172=1;  \r
+  is173=0;\r
+  info->Power=UNL22211Power;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
+\r
+void Mapper173_Init(CartInfo *info)\r
+{\r
+  is172=0;  \r
+  is173=1;\r
+  info->Power=UNL22211Power;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
diff --git a/boards/103.c b/boards/103.c
new file mode 100644 (file)
index 0000000..e25f5fc
--- /dev/null
@@ -0,0 +1,125 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2007 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg0, reg1, reg2;\r
+static uint8 *WRAM=NULL;\r
+static uint32 WRAMSIZE;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&reg0, 1, "REG0"},\r
+  {&reg1, 1, "REG1"},\r
+  {&reg2, 1, "REG2"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setchr8(0);\r
+  setprg8(0x8000,0xc);\r
+  setprg8(0xe000,0xf);\r
+  if(reg2&0x10)\r
+  {\r
+    setprg8(0x6000,reg0);\r
+    setprg8(0xa000,0xd);\r
+    setprg8(0xc000,0xe);\r
+  }\r
+  else\r
+  {\r
+    setprg8r(0x10,0x6000,0);\r
+    setprg4(0xa000,(0xd<<1));\r
+    setprg2(0xb000,(0xd<<2)+2);\r
+    setprg2r(0x10,0xb800,4);\r
+    setprg2r(0x10,0xc000,5);\r
+    setprg2r(0x10,0xc800,6);\r
+    setprg2r(0x10,0xd000,7);\r
+    setprg2(0xd800,(0xe<<2)+3);\r
+  }\r
+  setmirror(reg1^1);\r
+}\r
+\r
+static DECLFW(M103RamWrite0)\r
+{\r
+  WRAM[A&0x1FFF]=V;\r
+}\r
+\r
+static DECLFW(M103RamWrite1)\r
+{\r
+  WRAM[0x2000+((A-0xB800)&0x1FFF)]=V;\r
+}\r
+\r
+static DECLFW(M103Write0)\r
+{\r
+  reg0=V&0xf;\r
+  Sync();\r
+}\r
+\r
+static DECLFW(M103Write1)\r
+{\r
+  reg1=(V>>3)&1;\r
+  Sync();\r
+}\r
+\r
+static DECLFW(M103Write2)\r
+{\r
+  reg2=V;\r
+  Sync();\r
+}\r
+\r
+static void M103Power(void)\r
+{\r
+  reg0=reg1=0; reg2=0;\r
+  Sync();\r
+  SetReadHandler(0x6000,0x7FFF,CartBR);\r
+  SetWriteHandler(0x6000,0x7FFF,M103RamWrite0);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0xB800,0xD7FF,M103RamWrite1);\r
+  SetWriteHandler(0x8000,0x8FFF,M103Write0);\r
+  SetWriteHandler(0xE000,0xEFFF,M103Write1);\r
+  SetWriteHandler(0xF000,0xFFFF,M103Write2);\r
+}\r
+\r
+static void M103Close(void)\r
+{\r
+  if(WRAM)\r
+    FCEU_gfree(WRAM);\r
+  WRAM=NULL;\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper103_Init(CartInfo *info)\r
+{\r
+  info->Power=M103Power;\r
+  info->Close=M103Close;\r
+  GameStateRestore=StateRestore;\r
+\r
+  WRAMSIZE=16384;\r
+  WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);\r
+  SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);\r
+  AddExState(WRAM, WRAMSIZE, 0, "WRAM");\r
+\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
diff --git a/boards/106.c b/boards/106.c
new file mode 100644 (file)
index 0000000..638dda9
--- /dev/null
@@ -0,0 +1,119 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2007 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg[16], IRQa;\r
+static uint32 IRQCount;\r
+static uint8 *WRAM=NULL;\r
+static uint32 WRAMSIZE;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&IRQa, 1, "IRQA"},\r
+  {&IRQCount, 4, "IRQCOUNT"},\r
+  {reg, 16, "REGS"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setchr1(0x0000,reg[0]&0xfe);\r
+  setchr1(0x0400,reg[1]|1);\r
+  setchr1(0x0800,reg[2]&0xfe);\r
+  setchr1(0x0c00,reg[3]|1);\r
+  setchr1(0x1000,reg[4]);\r
+  setchr1(0x1400,reg[5]);\r
+  setchr1(0x1800,reg[6]);\r
+  setchr1(0x1c00,reg[7]);\r
+  setprg8r(0x10,0x6000,0);\r
+  setprg8(0x8000,(reg[0x8]&0xf)|0x10);\r
+  setprg8(0xA000,(reg[0x9]&0x1f));\r
+  setprg8(0xC000,(reg[0xa]&0x1f));\r
+  setprg8(0xE000,(reg[0xb]&0xf)|0x10);\r
+  setmirror((reg[0xc]&1)^1);\r
+}\r
+\r
+static DECLFW(M106Write)\r
+{\r
+  A&=0xF;\r
+  switch(A)\r
+  {\r
+    case 0xD: IRQa=0; IRQCount=0; X6502_IRQEnd(FCEU_IQEXT); break;\r
+    case 0xE: IRQCount=(IRQCount&0xFF00)|V; break;\r
+    case 0xF: IRQCount=(IRQCount&0x00FF)|(V<<8); IRQa=1; break;\r
+    default: reg[A]=V; Sync(); break;\r
+  }\r
+}\r
+\r
+static void M106Power(void)\r
+{\r
+  reg[8]=reg[9]=reg[0xa]=reg[0xb]=-1;\r
+  Sync();\r
+  SetReadHandler(0x6000,0x7FFF,CartBR);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x6000,0x7FFF,CartBW);\r
+  SetWriteHandler(0x8000,0xFFFF,M106Write);\r
+}\r
+\r
+static void M106Reset(void)\r
+{\r
+}\r
+\r
+static void M106Close(void)\r
+{\r
+  if(WRAM)\r
+    FCEU_gfree(WRAM);\r
+  WRAM=NULL;\r
+}\r
+\r
+void M106CpuHook(int a)\r
+{\r
+  if(IRQa)\r
+  {\r
+    IRQCount+=a;\r
+    if(IRQCount>0x10000)\r
+    {\r
+      X6502_IRQBegin(FCEU_IQEXT);\r
+      IRQa=0;\r
+    }\r
+  }\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper106_Init(CartInfo *info)\r
+{\r
+  info->Reset=M106Reset;\r
+  info->Power=M106Power;\r
+  info->Close=M106Close;\r
+  MapIRQHook=M106CpuHook;\r
+  GameStateRestore=StateRestore;\r
+\r
+  WRAMSIZE=8192;\r
+  WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);\r
+  SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);\r
+  AddExState(WRAM, WRAMSIZE, 0, "WRAM");\r
+\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
similarity index 57%
rename from boards/bmcgk192.c
rename to boards/108.c
index b66d831..fc3aebd 100644 (file)
@@ -1,67 +1,62 @@
-/* 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");
-}
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2007 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&reg, 1, "REG"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setprg8(0x6000,reg);\r
+  setprg32(0x8000,~0);\r
+  setchr8(0);\r
+}\r
+\r
+static DECLFW(M108Write)\r
+{\r
+   reg=V;\r
+   Sync();\r
+}\r
+\r
+static void M108Power(void)\r
+{\r
+  Sync();\r
+  SetReadHandler(0x6000,0x7FFF,CartBR);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8FFF,0x8FFF,M108Write);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper108_Init(CartInfo *info)\r
+{\r
+  info->Power=M108Power;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
index 2bb1e4b..ccfd4f4 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * NTDEC, ASDER games
  */
 
 #include "mapinc.h"
 
 static uint8 reg[8];
-static uint8 mirror, cmd;
+static uint8 mirror, cmd, bank;
 static uint8 *WRAM=NULL;
 
 static SFORMAT StateRegs[]=
 {
   {&cmd, 1, "CMD"},
   {&mirror, 1, "MIRR"},
+  {&bank, 1, "BANK"},
   {reg, 8, "REGS"},
   {0}
 };
@@ -37,12 +39,12 @@ 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]);
+  setchr2(0x0000,(reg[2]>>1));
+  setchr2(0x0800,(reg[3]>>1));
+  setchr1(0x1000,((bank&0x10)<<4)|reg[4]);
+  setchr1(0x1400,((bank&0x20)<<3)|reg[5]);
+  setchr1(0x1800,((bank&0x40)<<2)|reg[6]);
+  setchr1(0x1C00,((bank&0x80)<<1)|reg[7]);
 }
 
 static DECLFW(M112Write)
@@ -52,8 +54,8 @@ static DECLFW(M112Write)
     case 0xe000: mirror=V&1; Sync(); ;break;
     case 0x8000: cmd=V&7; break;
     case 0xa000: reg[cmd]=V; Sync(); break;
+    case 0xc000: bank=V; Sync(); break;
   }
-FCEU_printf("%04x:%04x %d\n",A,V,scanline);
 }
 
 static void M112Close(void)
@@ -65,10 +67,12 @@ static void M112Close(void)
 
 static void M112Power(void)
 {
+  bank=0;
   setprg16(0xC000,~0);
   setprg8r(0x10,0x6000,0);
   SetReadHandler(0x8000,0xFFFF,CartBR);
   SetWriteHandler(0x8000,0xFFFF,M112Write);
+  SetWriteHandler(0x4020,0x5FFF,M112Write);
   SetReadHandler(0x6000,0x7FFF,CartBR);
   SetWriteHandler(0x6000,0x7FFF,CartBW);
 }
diff --git a/boards/116.c b/boards/116.c
new file mode 100644 (file)
index 0000000..3a21668
--- /dev/null
@@ -0,0 +1,359 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2011 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ * \r
+ * SL12 Protected 3-in-1 mapper hardware (VRC2, MMC3, MMC1)\r
+ * the same as 603-5052 board (TODO: add reading registers, merge)\r
+ * SL1632 2-in-1 protected board, similar to SL12 (TODO: find difference)\r
+ *\r
+ * Known PCB:\r
+ *\r
+ * Garou Densetsu Special (G0904.PCB, Huang-1, GAL dip: W conf.)\r
+ * Kart Fighter (008, Huang-1, GAL dip: W conf.)\r
+ * Somari (008, C5052-13, GAL dip: P conf., GK2-P/GK2-V maskroms)\r
+ * Somari (008, Huang-1, GAL dip: W conf., GK1-P/GK1-V maskroms)\r
+ * AV Mei Shao Nv Zhan Shi ()\r
+ * Samurai Spirits (Full version) (Huang-1, GAL dip: unk conf. GS-2A/GS-4A maskroms)\r
+ * Contra Fighter (603-5052 board, C5052-3, GAL dip: unk conf. SC603-A/SCB603-B maskroms)\r
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+#include "mmc3.h"\r
+\r
+static uint8 mode;\r
+static uint8 vrc2_chr[8], vrc2_prg[2], vrc2_mirr;\r
+static uint8 mmc3_regs[10], mmc3_ctrl, mmc3_mirr;\r
+extern uint8 IRQCount,IRQLatch,IRQa;\r
+extern uint8 IRQReload;\r
+static uint8 mmc1_regs[4], mmc1_buffer, mmc1_shift;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&mode, 1, "MODE"},\r
+  {vrc2_chr, 8, "vrch"},\r
+  {vrc2_prg, 2, "vrpr"},\r
+  {&vrc2_mirr, 1, "vrmi"},\r
+  {mmc3_regs, 10, "m3re"},\r
+  {&mmc3_ctrl, 1, "m3ct"},\r
+  {&mmc3_mirr, 1, "m3mi"},\r
+  {&IRQReload, 1, "IRQR"},\r
+  {&IRQCount, 1, "IRQC"},\r
+  {&IRQLatch, 1, "IRQL"},\r
+  {&IRQa, 1, "IRQA"},\r
+  {mmc1_regs, 4, "m1r"},\r
+  {&mmc1_buffer, 1, "m1bf"},\r
+  {&mmc1_shift, 1, "m1mi"},\r
+  {0}\r
+};\r
+\r
+static void SyncPRG(void)\r
+{\r
+  switch(mode & 3) {\r
+   case 0:\r
+     setprg8(0x8000, vrc2_prg[0]);\r
+     setprg8(0xA000, vrc2_prg[1]);\r
+     setprg8(0xC000, ~1);\r
+     setprg8(0xE000, ~0);\r
+     break;\r
+   case 1: {\r
+     uint32 swap = (mmc3_ctrl >> 5) & 2;\r
+     setprg8(0x8000, mmc3_regs[6 + swap]);\r
+     setprg8(0xA000, mmc3_regs[7]);\r
+     setprg8(0xC000, mmc3_regs[6 + (swap ^ 2)]);\r
+     setprg8(0xE000, mmc3_regs[9]);\r
+     break;\r
+   }\r
+   case 2:\r
+   case 3: {\r
+     uint8 bank = mmc1_regs[3] & 0xF;\r
+        if(mmc1_regs[0] & 8)\r
+     {\r
+       if(mmc1_regs[0] & 4)\r
+       {\r
+         setprg16(0x8000, bank);\r
+         setprg16(0xC000, 0x0F);\r
+       }\r
+       else\r
+       {\r
+         setprg16(0x8000, 0);\r
+         setprg16(0xC000, bank);\r
+       }\r
+     }\r
+        else\r
+          setprg32(0x8000, bank >> 1);\r
+     break;\r
+   }\r
+  }\r
+}\r
+\r
+static void SyncCHR(void)\r
+{\r
+  uint32 base = (mode & 4) << 6;\r
+  switch(mode & 3) {\r
+   case 0:\r
+     setchr1(0x0000, base|vrc2_chr[0]);\r
+     setchr1(0x0400, base|vrc2_chr[1]);\r
+     setchr1(0x0800, base|vrc2_chr[2]);\r
+     setchr1(0x0c00, base|vrc2_chr[3]);\r
+     setchr1(0x1000, base|vrc2_chr[4]);\r
+     setchr1(0x1400, base|vrc2_chr[5]);\r
+     setchr1(0x1800, base|vrc2_chr[6]);\r
+     setchr1(0x1c00, base|vrc2_chr[7]);\r
+     break;\r
+   case 1: {\r
+     uint32 swap = (mmc3_ctrl & 0x80) << 5;\r
+     setchr1(0x0000 ^ swap, base|((mmc3_regs[0])&0xFE));\r
+     setchr1(0x0400 ^ swap, base|(mmc3_regs[0]|1));\r
+     setchr1(0x0800 ^ swap, base|((mmc3_regs[1])&0xFE));\r
+     setchr1(0x0c00 ^ swap, base|(mmc3_regs[1]|1));\r
+     setchr1(0x1000 ^ swap, base|mmc3_regs[2]);\r
+     setchr1(0x1400 ^ swap, base|mmc3_regs[3]);\r
+     setchr1(0x1800 ^ swap, base|mmc3_regs[4]);\r
+     setchr1(0x1c00 ^ swap, base|mmc3_regs[5]);\r
+     break;\r
+   }\r
+   case 2:\r
+   case 3:\r
+     if(mmc1_regs[0]&0x10)\r
+     {\r
+       setchr4(0x0000, mmc1_regs[1]);\r
+       setchr4(0x1000, mmc1_regs[2]);\r
+     }\r
+     else\r
+       setchr8(mmc1_regs[1] >> 1);\r
+     break;\r
+  }\r
+}\r
+\r
+static void SyncMIR(void)\r
+{\r
+  switch(mode & 3) {\r
+   case 0: {\r
+     setmirror((vrc2_mirr&1)^1);\r
+     break;\r
+   }\r
+   case 1: {\r
+     setmirror((mmc3_mirr&1)^1);\r
+     break;\r
+   }\r
+   case 2:\r
+   case 3: {\r
+     switch(mmc1_regs[0]&3) {\r
+       case 0: setmirror(MI_0); break;\r
+       case 1: setmirror(MI_1); break;\r
+       case 2: setmirror(MI_V); break;\r
+       case 3: setmirror(MI_H); break;\r
+     }\r
+     break;\r
+   }\r
+  }\r
+}\r
+\r
+static void Sync(void)\r
+{\r
+  SyncPRG();\r
+  SyncCHR();\r
+  SyncMIR();\r
+}\r
+\r
+static DECLFW(UNLSL12ModeWrite)\r
+{\r
+  printf("%04X:%02X\n",A,V);\r
+  if((A & 0x4100) == 0x4100) {\r
+    mode = V;\r
+    if(A&1) { // hacky hacky, there are two configuration modes on SOMARI HUANG-1 PCBs\r
+              // Solder pads with P1/P2 shorted called SOMARI P,\r
+              // Solder pads with W1/W2 shorted called SOMARI W\r
+              // Both identical 3-in-1 but W wanted MMC1 registers\r
+              // to be reset when switch to MMC1 mode P one - doesn't\r
+              // There is issue with W version of Somari at starting copyrights\r
+      mmc1_regs[0] = 0xc;\r
+      mmc1_regs[3] = 0;\r
+      mmc1_buffer = 0;\r
+      mmc1_shift = 0;\r
+    }\r
+    Sync();\r
+  }\r
+}\r
+\r
+static DECLFW(UNLSL12Write)\r
+{\r
+  printf("%04X:%02X\n",A,V);\r
+       if(A==0xA123)\r
+       {\r
+               int zzz=9;\r
+       }\r
+  switch(mode & 3) {\r
+   case 0: {\r
+     if((A>=0xB000)&&(A<=0xE003))\r
+     {\r
+       int32 ind=((((A&2)|(A>>10))>>1)+2)&7;\r
+       int32 sar=((A&1)<<2);\r
+       vrc2_chr[ind]=(vrc2_chr[ind]&(0xF0>>sar))|((V&0x0F)<<sar);\r
+       SyncCHR();\r
+     }\r
+     else\r
+       switch(A&0xF000) {\r
+        case 0x8000: vrc2_prg[0] = V; SyncPRG(); break;\r
+        case 0xA000: vrc2_prg[1] = V; SyncPRG(); break;\r
+        case 0x9000: vrc2_mirr = V; SyncMIR(); break;\r
+       }\r
+     break;\r
+   }\r
+   case 1: {\r
+     switch(A & 0xE001) {\r
+      case 0x8000: {\r
+        uint8 old_ctrl = mmc3_ctrl;\r
+        mmc3_ctrl = V;\r
+        if((old_ctrl&0x40) != (mmc3_ctrl&0x40))\r
+          SyncPRG();\r
+        if((old_ctrl&0x80) != (mmc3_ctrl&0x80))\r
+          SyncCHR();\r
+        break;\r
+      }\r
+      case 0x8001:\r
+        mmc3_regs[mmc3_ctrl & 7] = V;\r
+        if((mmc3_ctrl & 7) < 6)\r
+          SyncCHR();\r
+        else\r
+          SyncPRG();\r
+        break;\r
+      case 0xA000:\r
+        mmc3_mirr = V;\r
+        SyncMIR();\r
+        break;\r
+      case 0xC000:\r
+        IRQLatch = V;\r
+        break;\r
+      case 0xC001:\r
+        IRQReload = 1;\r
+        break;\r
+      case 0xE000:\r
+        X6502_IRQEnd(FCEU_IQEXT);\r
+        IRQa=0;\r
+        break;\r
+      case 0xE001:\r
+        IRQa=1;\r
+        break;\r
+     }\r
+     break;\r
+   }\r
+   case 2:\r
+   case 3: {\r
+     if(V & 0x80)\r
+     {\r
+       mmc1_regs[0] |= 0xc;\r
+       mmc1_buffer = mmc1_shift = 0;\r
+       SyncPRG();\r
+     }\r
+     else\r
+     {\r
+       uint8 n = (A >> 13) - 4;\r
+       mmc1_buffer |=  (V & 1) << (mmc1_shift++);\r
+       if(mmc1_shift == 5)\r
+       {\r
+         mmc1_regs[n] = mmc1_buffer;\r
+         mmc1_buffer = mmc1_shift = 0;\r
+         switch(n) {\r
+          case 0: SyncMIR();\r
+          case 2: SyncCHR(); \r
+          case 3:\r
+          case 1: SyncPRG();\r
+         }\r
+       }\r
+     }\r
+     break;\r
+   }\r
+  }\r
+}\r
+\r
+static void UNLSL12HBIRQ(void)\r
+{\r
+  if((mode & 3) == 1)\r
+  {\r
+    int32 count = IRQCount;\r
+    if(!count || IRQReload)\r
+    {\r
+      IRQCount = IRQLatch;\r
+      IRQReload = 0;\r
+    }\r
+    else\r
+      IRQCount--;\r
+    if(!IRQCount)\r
+    {\r
+      if(IRQa)\r
+        X6502_IRQBegin(FCEU_IQEXT);\r
+    }\r
+  }\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+static void UNLSL12Power(void)\r
+{\r
+  mode = 0;\r
+  vrc2_chr[0] = ~0;\r
+  vrc2_chr[1] = ~0;\r
+  vrc2_chr[2] = ~0;\r
+  vrc2_chr[3] = ~0; // W conf. of Somari wanted CHR3 has to be set to BB bank (or similar), but doesn't do that directly\r
+  vrc2_chr[4] = 4;\r
+  vrc2_chr[5] = 5;\r
+  vrc2_chr[6] = 6;\r
+  vrc2_chr[7] = 7;\r
+  vrc2_prg[0] = 0;\r
+  vrc2_prg[1] = 1;\r
+  vrc2_mirr = 0;\r
+  mmc3_regs[0] = 0;\r
+  mmc3_regs[1] = 2;\r
+  mmc3_regs[2] = 4;\r
+  mmc3_regs[3] = 5;\r
+  mmc3_regs[4] = 6;\r
+  mmc3_regs[5] = 7;\r
+  mmc3_regs[6] = ~3;\r
+  mmc3_regs[7] = ~2;\r
+  mmc3_regs[8] = ~1;\r
+  mmc3_regs[9] = ~0;\r
+  mmc3_ctrl = mmc3_mirr = IRQCount = IRQLatch = IRQa = 0;\r
+  mmc1_regs[0] = 0xc;\r
+  mmc1_regs[1] = 0;\r
+  mmc1_regs[2] = 0;\r
+  mmc1_regs[3] = 0;\r
+  mmc1_buffer = 0;\r
+  mmc1_shift = 0;\r
+  Sync();\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x4100,0x7FFF,UNLSL12ModeWrite);\r
+  SetWriteHandler(0x8000,0xFFFF,UNLSL12Write);\r
+}\r
+\r
+void UNLSL12_Init(CartInfo *info)\r
+{\r
+  info->Power = UNLSL12Power;\r
+  GameHBIRQHook = UNLSL12HBIRQ;\r
+  GameStateRestore = StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
+\r
+void Mapper116_Init(CartInfo *info)\r
+{\r
+       UNLSL12_Init(info);\r
+}\r
index 6746015..b2348f0 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 #include "mapinc.h"
 
-static uint8 prgreg[4], chrreg[8];
+static uint8 prgreg[4], chrreg[8], mirror;
 static uint8 IRQa, IRQCount, IRQLatch;
 
 static SFORMAT StateRegs[]=
@@ -30,18 +30,20 @@ static SFORMAT StateRegs[]=
   {&IRQLatch, 1, "IRQL"},
   {prgreg, 4, "PREGS"},
   {chrreg, 8, "CREGS"},
+  {&mirror, 1, "MREG"},
   {0}
 };
 
 static void Sync(void)
 {
+  int i;
   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]);     
+  setmirror(mirror^1);   
 }
 
 static DECLFW(M117Write)
@@ -62,6 +64,7 @@ static DECLFW(M117Write)
          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;
+         case 0xd000: mirror=V&1;
        }
 }
 
diff --git a/boards/120.c b/boards/120.c
new file mode 100644 (file)
index 0000000..ed681b9
--- /dev/null
@@ -0,0 +1,66 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2007 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&reg, 1, "REG"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setprg8(0x6000,reg);\r
+  setprg32(0x8000,2);\r
+  setchr8(0);\r
+}\r
+\r
+static DECLFW(M120Write)\r
+{\r
+   if(A==0x41FF)\r
+   {\r
+     reg=V&7;\r
+     Sync();\r
+   }\r
+}\r
+\r
+static void M120Power(void)\r
+{\r
+  reg=0;\r
+  Sync();\r
+  SetReadHandler(0x6000,0x7FFF,CartBR);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x4100,0x5FFF,M120Write);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper120_Init(CartInfo *info)\r
+{\r
+  info->Power=M120Power;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
diff --git a/boards/121.c b/boards/121.c
new file mode 100644 (file)
index 0000000..63784f9
--- /dev/null
@@ -0,0 +1,91 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2007-2008 Mad Dumper, CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ * Panda prince pirate.\r
+ * MK4, MK6, A9711 board, MAPPER 187 the same!\r
+ * UNL6035052_Init seems to be the same too, but with prot array in reverse\r
+ */\r
+\r
+#include "mapinc.h"\r
+#include "mmc3.h"\r
+\r
+static uint8 readbyte = 0;\r
+\r
+static DECLFW(M121Write)\r
+{\r
+//  FCEU_printf("write: %04x:%04x\n",A&0xE003,V);\r
+  if((A&0xF003)==0x8003)\r
+  {\r
+//    FCEU_printf("       prot write");\r
+//    FCEU_printf("write: %04x:%04x\n",A,V);\r
+    if     (V==0xAB) setprg8(0xE000,7);\r
+    else if(V==0x26) setprg8(0xE000,8);\r
+//    else if(V==0x26) setprg8(0xE000,1); // MK3\r
+//    else if(V==0x26) setprg8(0xE000,0x15); // sonic 3D blast, 8003 - command (0x26), 8001 - data 0x2A (<<1 = 0x15)\r
+    else if(V==0xFF) setprg8(0xE000,9);\r
+    else if(V==0x28) setprg8(0xC000,0xC);\r
+    else if(V==0xEC) setprg8(0xE000,0xD); \r
+//    else if(V==0xEC) setprg8(0xE000,0xC);//MK3\r
+    else if(V==0xEF) setprg8(0xE000,0xD); // damn mess, need real hardware to figure out bankswitching\r
+    else if(V==0x2A) setprg8(0xA000,0x0E);\r
+//    else if(V==0x2A) setprg8(0xE000,0x0C); // MK3\r
+    else if(V==0x20) setprg8(0xE000,0x13);\r
+    else if(V==0x29) setprg8(0xE000,0x1B);\r
+    else \r
+    {\r
+//      FCEU_printf(" unknown");\r
+      FixMMC3PRG(MMC3_cmd);\r
+      MMC3_CMDWrite(A,V);\r
+    }\r
+//      FCEU_printf("\n");\r
+  }\r
+  else\r
+  {\r
+//    FixMMC3PRG(MMC3_cmd);\r
+    MMC3_CMDWrite(A,V);\r
+  }\r
+}\r
+\r
+static uint8 prot_array[16] = { 0x83, 0x83, 0x42, 0x00 };\r
+static DECLFW(M121LoWrite)\r
+{\r
+  EXPREGS[0] = prot_array[V&3];  // 0x100 bit in address seems to be switch arrays 0, 2, 2, 3 (Contra Fighter)\r
+//  FCEU_printf("write: %04x:%04x\n",A,V);\r
+}\r
+\r
+static DECLFR(M121Read)\r
+{ \r
+//  FCEU_printf("read:  %04x\n",A);\r
+  return EXPREGS[0];\r
+}\r
+\r
+static void M121Power(void)\r
+{\r
+  GenMMC3Power();\r
+//  Write_IRQFM(0x4017,0x40);\r
+  SetReadHandler(0x5000,0x5FFF,M121Read);\r
+  SetWriteHandler(0x5000,0x5FFF,M121LoWrite);\r
+  SetWriteHandler(0x8000,0x9FFF,M121Write);\r
+}\r
+\r
+void Mapper121_Init(CartInfo *info)\r
+{\r
+  GenMMC3_Init(info, 128, 256, 8, 0);\r
+  info->Power=M121Power;\r
+  AddExState(EXPREGS, 2, 0, "EXPR");\r
+}\r
diff --git a/boards/15.c b/boards/15.c
new file mode 100644 (file)
index 0000000..6405afa
--- /dev/null
@@ -0,0 +1,120 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2006 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint16 latchea;\r
+static uint8 latched;\r
+static uint8 *WRAM=NULL;\r
+static uint32 WRAMSIZE;\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&latchea, 2, "AREG"},\r
+  {&latched, 1, "DREG"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  int i;\r
+  setmirror(((latched>>6)&1)^1);\r
+  switch(latchea)\r
+  {\r
+    case 0x8000:\r
+      for(i=0;i<4;i++)\r
+        setprg8(0x8000+(i<<13),(((latched&0x7F)<<1)+i)^(latched>>7));\r
+      break;\r
+    case 0x8002:\r
+      for(i=0;i<4;i++)\r
+        setprg8(0x8000+(i<<13),((latched&0x7F)<<1)+(latched>>7));\r
+      break;\r
+    case 0x8001:\r
+    case 0x8003:\r
+      for(i=0;i<4;i++)\r
+      {\r
+        unsigned int b;\r
+        b=latched&0x7F;\r
+        if(i>=2 && !(latchea&0x2))\r
+          i=0x7F;\r
+        setprg8(0x8000+(i<<13),(i&1)+((b<<1)^(latched>>7)));\r
+      }\r
+      break;\r
+  }\r
+}\r
+\r
+static DECLFW(M15Write)\r
+{\r
+  latchea=A;\r
+  latched=V;\r
+       printf("%04X = %02X\n",A,V);\r
+  Sync();\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+static void M15Power(void)\r
+{\r
+  latchea=0x8000;\r
+  latched=0;\r
+  setchr8(0);\r
+  setprg8r(0x10,0x6000,0);\r
+  SetReadHandler(0x6000,0x7FFF,CartBR);\r
+  SetWriteHandler(0x6000,0x7FFF,CartBW);\r
+  SetWriteHandler(0x8000,0xFFFF,M15Write);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  Sync();\r
+}\r
+\r
+static void M15Reset(void)\r
+{\r
+  latchea=0x8000;\r
+  latched=0;\r
+  Sync();\r
+}\r
+\r
+static void M15Close(void)\r
+{\r
+  if(WRAM)\r
+    FCEU_gfree(WRAM);\r
+  WRAM=NULL;\r
+}\r
+\r
+void Mapper15_Init(CartInfo *info)\r
+{\r
+  info->Power=M15Power;\r
+  info->Reset=M15Reset;\r
+  info->Close=M15Close;\r
+  GameStateRestore=StateRestore;\r
+  WRAMSIZE=8192;\r
+  WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);\r
+  SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);\r
+  if(info->battery)\r
+  {\r
+    info->SaveGame[0]=WRAM;\r
+    info->SaveGameLen[0]=WRAMSIZE;\r
+  }\r
+  AddExState(WRAM, WRAMSIZE, 0, "WRAM");\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
+\r
index 0bb85b3..22589ec 100644 (file)
@@ -1,7 +1,7 @@
 /* FCE Ultra - NES/Famicom Emulator
  *
  * Copyright notice for this file:
- *  Copyright (C) 2002 Xodnizel
+ *  Copyright (C) 2002 Xodnizel 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
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 #include "mapinc.h"
 
-static uint8 cmd;
+static uint8 cmd, laststrobe, trigger;
 static uint8 DRegs[8];
 static SFORMAT StateRegs[]=
 {
   {&cmd, 1, "CMD"},
+  {&laststrobe, 1, "STB"},
+  {&trigger, 1, "TRG"},
   {DRegs, 8, "DREG"},
   {0}
 };
@@ -32,7 +34,6 @@ static SFORMAT StateRegs[]=
 static void Sync(void)
 {
   setprg32(0x8000,(DRegs[0]<<4)|(DRegs[1]&0xF));
-  setchr8(0);
 }
 
 static void StateRestore(int version)
@@ -40,21 +41,46 @@ static void StateRestore(int version)
   Sync();
 }
 
+static DECLFR(ReadLow)
+{
+  switch (A&0x7700)
+  {
+    case 0x5100: return DRegs[2]; break;
+    case 0x5500: if(trigger)
+                   return DRegs[2];
+                 else
+                   return 0;
+  }
+  return 4;
+}
+
 static DECLFW(Write)
 {
   switch (A&0x7300)
   {
     case 0x5100: DRegs[0]=V; Sync(); break;
     case 0x5000: DRegs[1]=V; Sync(); break;
+    case 0x5300: DRegs[2]=V; break;
   }
 }
 
 static DECLFW(Write2)
 {
+  if(A==0x5101)
+  {
+    if(laststrobe&&!V)
+    {
+      trigger^=1;
+    }
+    laststrobe=V;
+  }else if(A==0x5100&&V==6) //damn thoose protected games
+    setprg32(0x8000,3);
+  else
   switch (A&0x7300)
   {
     case 0x5200: DRegs[0]=V; Sync(); break;
-    case 0x5000: DRegs[1]=V; Sync(); break;
+    case 0x5000: DRegs[1]=V; Sync(); if(!(DRegs[1]&0x80)&&(scanline<128)) setchr8(0); break;
+    case 0x5300: DRegs[2]=V; break;
   }
 }
 
@@ -75,28 +101,42 @@ static void Power(void)
   DRegs[1]=0xFF;
   cmd=0;
   SetReadHandler(0x8000,0xFFFF,CartBR);
-  SetWriteHandler(0x4020,0xFFFF,Write);
+  SetWriteHandler(0x4020,0x5FFF,Write);
   SetReadHandler(0x6000,0x7FFF,AWRAM);
   SetWriteHandler(0x6000,0x7FFF,BWRAM);
+  setchr8(0);
   Sync();
 }
 
 static void M163HB(void)
 {
-  if(scanline==127&&DRegs[1]&0x80)
-    setchr4(0x0000,1);
+    if(DRegs[1]&0x80)
+    {
+      if(scanline==239)
+      {
+        setchr4(0x0000,0);
+        setchr4(0x1000,0);
+      }
+      else if(scanline==127)
+      {
+        setchr4(0x0000,1);
+        setchr4(0x1000,1);
+      }
+    }
 }
 
-
 static void Power2(void)
 {
   memset(DRegs,0,8);
   DRegs[1]=0xFF;
+  laststrobe=1;
   cmd=0;
   SetReadHandler(0x8000,0xFFFF,CartBR);
-  SetWriteHandler(0x4020,0xFFFF,Write2);
+  SetWriteHandler(0x4020,0x5FFF,Write2);
   SetReadHandler(0x6000,0x7FFF,AWRAM);
   SetWriteHandler(0x6000,0x7FFF,BWRAM);
+  SetReadHandler(0x5000,0x5FFF,ReadLow);
+  setchr8(0);
   Sync();
 }
 
@@ -105,6 +145,9 @@ void Mapper164_Init(CartInfo *info)
   info->Power=Power;
   GameStateRestore=StateRestore;
   AddExState(&StateRegs, ~0, 0, 0);
+  AddExState(WRAM, 8192, 0, "WRAM");
+  info->SaveGame[0]=WRAM;\r
+  info->SaveGameLen[0]=8192;
 }
 
 void Mapper163_Init(CartInfo *info)
@@ -113,4 +156,5 @@ void Mapper163_Init(CartInfo *info)
   GameHBIRQHook=M163HB;
   GameStateRestore=StateRestore;
   AddExState(&StateRegs, ~0, 0, 0);
+  AddExState(WRAM, 8192, 0, "WRAM");
 }
diff --git a/boards/175.c b/boards/175.c
new file mode 100644 (file)
index 0000000..2830584
--- /dev/null
@@ -0,0 +1,88 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2007 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg, delay, mirr;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&reg, 1, "REG"},\r
+  {&mirr, 1, "MIRR"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setchr8(reg);\r
+  if(!delay)\r
+  {\r
+  setprg16(0x8000,reg);\r
+  setprg8(0xC000,reg << 1);\r
+  }\r
+  setprg8(0xE000,(reg << 1) + 1);\r
+  setmirror(((mirr&4)>>2)^1);\r
+}\r
+\r
+static DECLFW(M175Write1)\r
+{\r
+  mirr = V;\r
+  delay = 1;\r
+  Sync();\r
+}\r
+\r
+static DECLFW(M175Write2)\r
+{\r
+  reg = V & 0x0F;\r
+  delay = 1;\r
+  Sync();\r
+}\r
+\r
+static DECLFR(M175Read)\r
+{\r
+  if(A==0xFFFC)\r
+  {\r
+    delay = 0;\r
+    Sync();\r
+  }\r
+  return CartBR(A);\r
+}\r
+\r
+static void M175Power(void)\r
+{\r
+  reg = mirr = delay = 0;\r
+  SetReadHandler(0x8000,0xFFFF,M175Read);\r
+  SetWriteHandler(0x8000,0x8000,M175Write1);\r
+  SetWriteHandler(0xA000,0xA000,M175Write2);\r
+  Sync();     \r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper175_Init(CartInfo *info)\r
+{\r
+  info->Power=M175Power;\r
+  GameStateRestore=StateRestore;\r
+\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
diff --git a/boards/176.c b/boards/176.c
new file mode 100644 (file)
index 0000000..0830df8
--- /dev/null
@@ -0,0 +1,158 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2007 CaH4e3\r
+ *  Copyright (C) 2012 FCEUX team\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+extern uint32 ROM_size;\r
+\r
+static uint8 prg[4], chr, sbw, we_sram;\r
+static uint8 *WRAM=NULL;\r
+static uint32 WRAMSIZE;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {prg, 4, "PRG"},\r
+  {&chr, 1, "CHR"},\r
+       {&sbw, 1, "SBW"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setprg8r(0x10,0x6000,0);\r
+       setprg8(0x8000,prg[0]);\r
+       setprg8(0xA000,prg[1]);\r
+       setprg8(0xC000,prg[2]);\r
+       setprg8(0xE000,prg[3]);\r
+\r
+  setchr8(chr);\r
+}\r
+\r
+static DECLFW(M176Write_5001)\r
+{ \r
+       printf("%04X = $%02X\n",A,V);\r
+       if(sbw)\r
+       {\r
+               prg[0] = V*4;\r
+               prg[1] = V*4+1;\r
+               prg[2] = V*4+2;\r
+               prg[3] = V*4+3;\r
+       }\r
+  Sync();\r
+}\r
+\r
+static DECLFW(M176Write_5010)\r
+{ \r
+       printf("%04X = $%02X\n",A,V);\r
+       if(V == 0x24) sbw = 1;\r
+  Sync();\r
+}\r
+\r
+static DECLFW(M176Write_5011)\r
+{ \r
+       printf("%04X = $%02X\n",A,V);\r
+       V >>= 1;\r
+       if(sbw)\r
+       {\r
+               prg[0] = V*4;\r
+               prg[1] = V*4+1;\r
+               prg[2] = V*4+2;\r
+               prg[3] = V*4+3;\r
+       }\r
+  Sync();\r
+}\r
+\r
+static DECLFW(M176Write_5FF1)\r
+{ \r
+       printf("%04X = $%02X\n",A,V);\r
+  V >>= 1;\r
+       prg[0] = V*4;\r
+       prg[1] = V*4+1;\r
+       prg[2] = V*4+2;\r
+       prg[3] = V*4+3;\r
+  Sync();\r
+}\r
+\r
+static DECLFW(M176Write_5FF2)\r
+{ \r
+       printf("%04X = $%02X\n",A,V);\r
+  chr = V;\r
+  Sync();\r
+}\r
+\r
+static DECLFW(M176Write_A001)\r
+{\r
+       we_sram = V & 0x03;\r
+}\r
+\r
+static DECLFW(M176Write_WriteSRAM)\r
+{\r
+//     if(we_sram)\r
+               CartBW(A,V);\r
+}\r
+\r
+static void M176Power(void)\r
+{\r
+  SetReadHandler(0x6000,0x7fff,CartBR);\r
+  SetWriteHandler(0x6000,0x7fff,M176Write_WriteSRAM);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+       SetWriteHandler(0xA001,0xA001,M176Write_A001);\r
+       SetWriteHandler(0x5001,0x5001,M176Write_5001);\r
+       SetWriteHandler(0x5010,0x5010,M176Write_5010);\r
+       SetWriteHandler(0x5011,0x5011,M176Write_5011);\r
+  SetWriteHandler(0x5ff1,0x5ff1,M176Write_5FF1);\r
+  SetWriteHandler(0x5ff2,0x5ff2,M176Write_5FF2);\r
+       \r
+       we_sram = 0;\r
+       sbw = 0;\r
+       prg[0] = 0;\r
+       prg[1] = 1;\r
+       prg[2] = (ROM_size-2)&63;\r
+       prg[3] = (ROM_size-1)&63;\r
+  Sync();\r
+}\r
+\r
+\r
+static void M176Close(void)\r
+{\r
+  if(WRAM)\r
+    FCEU_gfree(WRAM);\r
+  WRAM=NULL;\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper176_Init(CartInfo *info)\r
+{\r
+  info->Power=M176Power;\r
+  info->Close=M176Close;\r
+\r
+  GameStateRestore=StateRestore;\r
+\r
+  WRAMSIZE=8192;\r
+  WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);\r
+  SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);\r
+  AddExState(WRAM, WRAMSIZE, 0, "WRAM");\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
diff --git a/boards/177.c b/boards/177.c
new file mode 100644 (file)
index 0000000..6bc81b9
--- /dev/null
@@ -0,0 +1,87 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2007 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg;\r
+\r
+static uint8 *WRAM=NULL;\r
+static uint32 WRAMSIZE;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&reg, 1, "REG"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setchr8(0);\r
+  setprg8r(0x10,0x6000,0);\r
+  setprg32(0x8000,reg&0x1f);\r
+  setmirror(((reg&0x20)>>5)^1);\r
+}\r
+\r
+static DECLFW(M177Write)\r
+{\r
+  reg=V;\r
+  Sync();\r
+}\r
+\r
+static void M177Power(void)\r
+{\r
+  reg=0;\r
+  Sync();     \r
+  SetReadHandler(0x6000,0x7fff,CartBR);\r
+  SetWriteHandler(0x6000,0x7fff,CartBW);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0xFFFF,M177Write);\r
+}\r
+\r
+static void M177Close(void)\r
+{\r
+  if(WRAM)\r
+    FCEU_gfree(WRAM);\r
+  WRAM=NULL;\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper177_Init(CartInfo *info)\r
+{\r
+  info->Power=M177Power;\r
+  info->Close=M177Close;\r
+  GameStateRestore=StateRestore;\r
+\r
+  WRAMSIZE=8192;\r
+  WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);\r
+  SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);\r
+  AddExState(WRAM, WRAMSIZE, 0, "WRAM");\r
+  if(info->battery)\r
+  {\r
+    info->SaveGame[0]=WRAM;\r
+    info->SaveGameLen[0]=WRAMSIZE;\r
+  }\r
+\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
diff --git a/boards/178.c b/boards/178.c
new file mode 100644 (file)
index 0000000..19e1b8d
--- /dev/null
@@ -0,0 +1,101 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2007 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg[3];\r
+static uint8 *WRAM=NULL;\r
+static uint32 WRAMSIZE;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {reg, 3, "REGS"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setmirror(reg[0]);\r
+  setprg8r(0x10,0x6000,0);\r
+  setchr8(0);\r
+  setprg32(0x8000,(reg[1]+reg[2]));\r
+}\r
+\r
+static DECLFW(M178Write0)\r
+{\r
+  reg[0]=(V&1)^1;\r
+  Sync();\r
+}\r
+\r
+static DECLFW(M178Write1)\r
+{\r
+  reg[1]=(V>>1)&0xf;\r
+  Sync();\r
+}\r
+\r
+static DECLFW(M178Write2)\r
+{\r
+  reg[2]=(V<<2);\r
+  Sync();\r
+}\r
+\r
+static void M178Power(void)\r
+{\r
+  reg[0]=1; reg[1]=0; reg[2]=0;\r
+  Sync();\r
+  SetReadHandler(0x6000,0x7FFF,CartBR);\r
+  SetWriteHandler(0x6000,0x7FFF,CartBW);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x4800,0x4800,M178Write0);\r
+  SetWriteHandler(0x4801,0x4801,M178Write1);\r
+  SetWriteHandler(0x4802,0x4802,M178Write2);\r
+}\r
+\r
+static void M178Close(void)\r
+{\r
+  if(WRAM)\r
+    FCEU_gfree(WRAM);\r
+  WRAM=NULL;\r
+}\r
+\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper178_Init(CartInfo *info)\r
+{\r
+  info->Power=M178Power;\r
+  info->Close=M178Close;\r
+  GameStateRestore=StateRestore;\r
+\r
+  WRAMSIZE=8192;\r
+  WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);\r
+  SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);\r
+  if(info->battery)\r
+  {\r
+    info->SaveGame[0]=WRAM;\r
+    info->SaveGameLen[0]=WRAMSIZE;\r
+  }\r
+  AddExState(WRAM, WRAMSIZE, 0, "WRAM");\r
+\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
diff --git a/boards/179.c b/boards/179.c
new file mode 100644 (file)
index 0000000..91a530f
--- /dev/null
@@ -0,0 +1,94 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2007 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg[2];\r
+\r
+static uint8 *WRAM=NULL;\r
+static uint32 WRAMSIZE;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {reg, 2, "REG"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setchr8(0);\r
+  setprg8r(0x10,0x6000,0);\r
+  setprg32(0x8000,reg[1]>>1);\r
+  setmirror((reg[0]&1)^1);\r
+}\r
+\r
+static DECLFW(M179Write)\r
+{\r
+  if(A==0xa000) reg[0]=V;\r
+  Sync();\r
+}\r
+\r
+static DECLFW(M179WriteLo)\r
+{\r
+  if(A==0x5ff1) reg[1]=V;\r
+  Sync();\r
+}\r
+\r
+static void M179Power(void)\r
+{\r
+  reg[0]=reg[1]=0;\r
+  Sync();     \r
+  SetWriteHandler(0x4020,0x5fff,M179WriteLo);\r
+  SetReadHandler(0x6000,0x7fff,CartBR);\r
+  SetWriteHandler(0x6000,0x7fff,CartBW);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0xFFFF,M179Write);\r
+}\r
+\r
+static void M179Close(void)\r
+{\r
+  if(WRAM)\r
+    FCEU_gfree(WRAM);\r
+  WRAM=NULL;\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper179_Init(CartInfo *info)\r
+{\r
+  info->Power=M179Power;\r
+  info->Close=M179Close;\r
+  GameStateRestore=StateRestore;\r
+\r
+  WRAMSIZE=8192;\r
+  WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);\r
+  SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);\r
+  AddExState(WRAM, WRAMSIZE, 0, "WRAM");\r
+  if(info->battery)\r
+  {\r
+    info->SaveGame[0]=WRAM;\r
+    info->SaveGameLen[0]=WRAMSIZE;\r
+  }\r
+\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
index 5e80a6b..bf0b7c0 100644 (file)
-/* 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);
-}
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2005 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ *\r
+ * Gimmick Bootleg (VRC4 mapper)\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 prg[4];\r
+static uint8 chr[8];\r
+static uint8 IRQCount;\r
+static uint8 IRQPre;\r
+static uint8 IRQa;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {prg, 4, "PRG"},\r
+  {chr, 8, "CHR"},\r
+  {&IRQCount, 1, "IRQCOUNT"},\r
+  {&IRQPre, 1, "IRQPRE"},\r
+  {&IRQa, 1, "IRQA"},\r
+  {0}\r
+};\r
+\r
+static void SyncPrg(void)\r
+{\r
+  setprg8(0x6000,0);\r
+  setprg8(0x8000,prg[0]);\r
+  setprg8(0xA000,prg[1]);\r
+  setprg8(0xC000,prg[2]);\r
+  setprg8(0xE000,~0);\r
+}\r
+\r
+static void SyncChr(void)\r
+{\r
+  int i;\r
+  for(i=0; i<8; i++)\r
+     setchr1(i<<10,chr[i]);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  SyncPrg();\r
+  SyncChr();\r
+}\r
+\r
+static DECLFW(M183Write)\r
+{\r
+  if(((A&0xF80C)>=0xB000)&&((A&0xF80C)<=0xE00C))\r
+  {\r
+    uint8 index=(((A>>11)-6)|(A>>3))&7;\r
+    chr[index]=(chr[index]&(0xF0>>(A&4)))|((V&0x0F)<<(A&4));\r
+    SyncChr();\r
+  }\r
+  else switch (A&0xF80C)\r
+  {\r
+    case 0x8800: prg[0]=V; SyncPrg(); break;\r
+    case 0xA800: prg[1]=V; SyncPrg(); break;\r
+    case 0xA000: prg[2]=V; SyncPrg(); break;\r
+    case 0x9800: switch (V&3)\r
+                 {\r
+                   case 0: setmirror(MI_V); break;\r
+                   case 1: setmirror(MI_H); break;\r
+                   case 2: setmirror(MI_0); break;\r
+                   case 3: setmirror(MI_1); break;\r
+                 }\r
+                 break;\r
+    case 0xF000: IRQCount=((IRQCount&0xF0)|(V&0xF)); break;\r
+    case 0xF004: IRQCount=((IRQCount&0x0F)|((V&0xF)<<4)); break;\r
+    case 0xF008: IRQa=V; if(!V)IRQPre=0; X6502_IRQEnd(FCEU_IQEXT); break;\r
+    case 0xF00C: IRQPre=16; break;\r
+  }\r
+}\r
+\r
+static void M183IRQCounter(void)\r
+{\r
+  if(IRQa)\r
+  {\r
+    IRQCount++;\r
+    if((IRQCount-IRQPre)==238)\r
+      X6502_IRQBegin(FCEU_IQEXT);\r
+  }\r
+}\r
+\r
+static void M183Power(void)\r
+{\r
+  IRQPre=IRQCount=IRQa=0;\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0xFFFF,M183Write);\r
+  SetReadHandler(0x6000,0x7FFF,CartBR);\r
+  SyncPrg();\r
+  SyncChr();\r
+}\r
+\r
+void Mapper183_Init(CartInfo *info)\r
+{\r
+  info->Power=M183Power;\r
+  GameHBIRQHook=M183IRQCounter;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
index 49b63dc..b865a8f 100644 (file)
-/* 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);
-}
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2005 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 *DummyCHR=NULL;\r
+static uint8 datareg;\r
+static void(*Sync)(void);\r
+\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&datareg, 1, "DREG"},\r
+  {0}\r
+};\r
+\r
+//   on    off\r
+//1  0x0F, 0xF0 - Bird Week\r
+//2  0x33, 0x00 - B-Wings\r
+//3  0x11, 0x00 - Mighty Bomb Jack\r
+//4  0x22, 0x20 - Sansuu 1 Nen, Sansuu 2 Nen\r
+//5  0xFF, 0x00 - Sansuu 3 Nen\r
+//6  0x21, 0x13 - Spy vs Spy\r
+//7  0x20, 0x21 - Seicross\r
+\r
+static void Sync185(void)\r
+{\r
+  // little dirty eh? ;_)\r
+  if((datareg&3)&&(datareg!=0x13)) // 1, 2, 3, 4, 5, 6\r
+   setchr8(0);\r
+  else\r
+   setchr8r(0x10,0);\r
+}\r
+\r
+static void Sync181(void)\r
+{\r
+  if(!(datareg&1))                      // 7\r
+   setchr8(0);\r
+  else\r
+   setchr8r(0x10,0);\r
+}\r
+\r
+static DECLFW(MWrite)\r
+{\r
+  datareg=V;\r
+  Sync();\r
+}\r
+\r
+static void MPower(void)\r
+{\r
+  datareg=0;\r
+  Sync();\r
+  setprg16(0x8000,0);\r
+  setprg16(0xC000,~0);\r
+  SetWriteHandler(0x8000,0xFFFF,MWrite);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+}\r
+\r
+static void MClose(void)\r
+{\r
+  if(DummyCHR)\r
+    FCEU_gfree(DummyCHR);\r
+  DummyCHR=NULL;\r
+}\r
+\r
+static void MRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper185_Init(CartInfo *info)\r
+{\r
+  int x;\r
+  Sync=Sync185;\r
+  info->Power=MPower;\r
+  info->Close=MClose;\r
+  GameStateRestore=MRestore;\r
+  DummyCHR=(uint8*)FCEU_gmalloc(8192);\r
+  for(x=0;x<8192;x++)\r
+     DummyCHR[x]=0xff;\r
+  SetupCartCHRMapping(0x10,DummyCHR,8192,0);\r
+  AddExState(StateRegs, ~0, 0, 0);\r
+}\r
+\r
+void Mapper181_Init(CartInfo *info)\r
+{\r
+  int x;\r
+  Sync=Sync181;\r
+  info->Power=MPower;\r
+  info->Close=MClose;\r
+  GameStateRestore=MRestore;\r
+  DummyCHR=(uint8*)FCEU_gmalloc(8192);\r
+  for(x=0;x<8192;x++)\r
+     DummyCHR[x]=0xff;\r
+  SetupCartCHRMapping(0x10,DummyCHR,8192,0);\r
+  AddExState(StateRegs, ~0, 0, 0);\r
+}\r
index 80b39d8..4976265 100644 (file)
-/* 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);
-}
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2005 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ *\r
+ * Family Study Box by Fukutake Shoten\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 SWRAM[2816];\r
+static uint8 *WRAM=NULL;\r
+static uint8 regs[4];\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {regs, 4, "DREG"},\r
+  {SWRAM, 2816, "SWRAM"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setprg8r(0x10,0x6000,regs[0]>>6);\r
+  setprg16(0x8000,regs[1]);\r
+  setprg16(0xc000,0);\r
+}\r
+\r
+static DECLFW(M186Write)\r
+{\r
+  if(A&0x4203) regs[A&3]=V;\r
+  Sync();\r
+}\r
+\r
+static DECLFR(M186Read)\r
+{\r
+  switch(A)\r
+  {\r
+    case 0x4200: return 0x00; break;\r
+    case 0x4201: return 0x00; break;\r
+    case 0x4202: return 0x40; break;\r
+    case 0x4203: return 0x00; break;\r
+  }\r
+  return 0xFF;\r
+}\r
+\r
+static DECLFR(ASWRAM)\r
+{\r
+  return(SWRAM[A-0x4400]);\r
+}\r
+static DECLFW(BSWRAM)\r
+{\r
+  SWRAM[A-0x4400]=V;\r
+}\r
+\r
+static void M186Power(void)\r
+{\r
+  setchr8(0);\r
+  SetReadHandler(0x6000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x6000,0xFFFF,CartBW);\r
+  SetReadHandler(0x4200,0x43FF,M186Read);\r
+  SetWriteHandler(0x4200,0x43FF,M186Write);\r
+  SetReadHandler(0x4400,0x4EFF,ASWRAM);\r
+  SetWriteHandler(0x4400,0x4EFF,BSWRAM);\r
+  regs[0]=regs[1]=regs[2]=regs[3];\r
+  Sync();\r
+}\r
+\r
+static void M186Close(void)\r
+{\r
+  if(WRAM)\r
+    FCEU_gfree(WRAM);\r
+  WRAM=NULL;\r
+}\r
+\r
+static void M186Restore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper186_Init(CartInfo *info)\r
+{\r
+  info->Power=M186Power;\r
+  info->Close=M186Close;\r
+  GameStateRestore=M186Restore;\r
+  WRAM=(uint8*)FCEU_gmalloc(32768);\r
+  SetupCartPRGMapping(0x10,WRAM,32768,1);\r
+  AddExState(WRAM, 32768, 0, "WRAM");\r
+  AddExState(StateRegs, ~0, 0, 0);\r
+}\r
index 0fa4a15..0f49748 100644 (file)
-/* 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");
-}
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2005 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+#include "mmc3.h"\r
+\r
+static void M187CW(uint32 A, uint8 V)\r
+{\r
+  if((A&0x1000)==((MMC3_cmd&0x80)<<5))\r
+    setchr1(A,V|0x100);\r
+  else\r
+    setchr1(A,V);\r
+}\r
+\r
+static void M187PW(uint32 A, uint8 V)\r
+{\r
+  if(EXPREGS[0]&0x80)\r
+  {\r
+    uint8 bank=EXPREGS[0]&0x1F;\r
+    if(EXPREGS[0]&0x20)\r
+      setprg32(0x8000,bank>>2);\r
+    else\r
+    {\r
+      setprg16(0x8000,bank);\r
+      setprg16(0xC000,bank);\r
+    }\r
+  }\r
+  else\r
+    setprg8(A,V&0x3F);\r
+}\r
+\r
+static DECLFW(M187Write8000)\r
+{\r
+  EXPREGS[2]=1;\r
+  MMC3_CMDWrite(A,V);\r
+}\r
+\r
+static DECLFW(M187Write8001)\r
+{\r
+  if(EXPREGS[2])\r
+    MMC3_CMDWrite(A,V);\r
+}\r
+\r
+static DECLFW(M187Write8003)\r
+{\r
+  EXPREGS[2]=0;\r
+  if(V==0x28)setprg8(0xC000,0x17);\r
+  else if(V==0x2A)setprg8(0xA000,0x0F);\r
+}\r
+\r
+\r
+static DECLFW(M187WriteLo)\r
+{\r
+  EXPREGS[1]=V;\r
+  if(A==0x5000)\r
+  {\r
+    EXPREGS[0]=V;\r
+    FixMMC3PRG(MMC3_cmd);\r
+  }\r
+}\r
+\r
+static uint8 prot_data[4] = { 0x83, 0x83, 0x42, 0x00 };\r
+static DECLFR(M187Read)\r
+{\r
+  return prot_data[EXPREGS[1]&3];\r
+}\r
+\r
+static void M187Power(void)\r
+{\r
+  EXPREGS[0]=EXPREGS[1]=EXPREGS[2]=0;\r
+  GenMMC3Power();\r
+  SetReadHandler(0x5000,0x5FFF,M187Read);\r
+  SetWriteHandler(0x5000,0x5FFF,M187WriteLo);\r
+  SetWriteHandler(0x8000,0x8000,M187Write8000);\r
+  SetWriteHandler(0x8001,0x8001,M187Write8001);\r
+  SetWriteHandler(0x8003,0x8003,M187Write8003);\r
+}\r
+\r
+void Mapper187_Init(CartInfo *info)\r
+{\r
+  GenMMC3_Init(info, 256, 256, 0, 0);\r
+  pwrap=M187PW;\r
+  cwrap=M187CW;\r
+  info->Power=M187Power;\r
+  AddExState(EXPREGS, 3, 0, "EXPR");\r
+}\r
index 23be63a..ff045a5 100644 (file)
@@ -1,48 +1,48 @@
-/* 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");
-}
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2005 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+#include "mmc3.h"\r
+\r
+static void M189PW(uint32 A, uint8 V)\r
+{\r
+  setprg32(0x8000,EXPREGS[0]&3);\r
+}\r
+\r
+static DECLFW(M189Write)\r
+{\r
+  EXPREGS[0]=V|(V>>4); //actually, there is a two versions of 189 mapper with hi or lo bits bankswitching.\r
+  FixMMC3PRG(MMC3_cmd);\r
+}\r
+\r
+static void M189Power(void)\r
+{\r
+  EXPREGS[0]=EXPREGS[1]=0;\r
+  GenMMC3Power();\r
+  SetWriteHandler(0x4120,0x7FFF,M189Write);\r
+}\r
+\r
+void Mapper189_Init(CartInfo *info)\r
+{\r
+  GenMMC3_Init(info, 256, 256, 0, 0);\r
+  pwrap=M189PW;\r
+  info->Power=M189Power;\r
+  AddExState(EXPREGS, 2, 0, "EXPR");\r
+}\r
diff --git a/boards/199.c b/boards/199.c
new file mode 100644 (file)
index 0000000..ed21278
--- /dev/null
@@ -0,0 +1,97 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2006 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ *\r
+ * Dragon Ball Z 2 - Gekishin Freeza! (C)\r
+ * Dragon Ball Z Gaiden - Saiya Jin Zetsumetsu Keikaku (C)\r
+ * San Guo Zhi 2 (C)\r
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+#include "mmc3.h"\r
+\r
+static uint8 *CHRRAM=NULL; // and here too\r
+\r
+static void M199PW(uint32 A, uint8 V)\r
+{\r
+  setprg8(A,V);\r
+  setprg8(0xC000,EXPREGS[0]);\r
+  setprg8(0xE000,EXPREGS[1]);\r
+}\r
+\r
+static void M199CW(uint32 A, uint8 V)\r
+{\r
+  setchr1r((V<8)?0x10:0x00,A,V);\r
+  setchr1r((DRegBuf[0]<8)?0x10:0x00,0x0000,DRegBuf[0]);\r
+  setchr1r((EXPREGS[2]<8)?0x10:0x00,0x0400,EXPREGS[2]);\r
+  setchr1r((DRegBuf[1]<8)?0x10:0x00,0x0800,DRegBuf[1]);\r
+  setchr1r((EXPREGS[3]<8)?0x10:0x00,0x0c00,EXPREGS[3]);\r
+}\r
+\r
+static void M199MW(uint8 V)\r
+{\r
+//    FCEU_printf("%02x\n",V);\r
+  switch(V&3)\r
+  {\r
+    case 0: setmirror(MI_V); break;\r
+    case 1: setmirror(MI_H); break;\r
+    case 2: setmirror(MI_0); break;\r
+    case 3: setmirror(MI_1); break;\r
+  }\r
+}\r
+\r
+static DECLFW(M199Write)\r
+{\r
+  if((A==0x8001)&&(MMC3_cmd&8))\r
+  {\r
+//    FCEU_printf("%02x=>%02x\n",MMC3_cmd,V);\r
+    EXPREGS[MMC3_cmd&3]=V;\r
+    FixMMC3PRG(MMC3_cmd);\r
+    FixMMC3CHR(MMC3_cmd);\r
+  }\r
+  else    \r
+    if(A<0xC000)\r
+      MMC3_CMDWrite(A,V);\r
+    else\r
+      MMC3_IRQWrite(A,V);\r
+}\r
+\r
+static void M199Power(void)\r
+{\r
+  EXPREGS[0]=~1;\r
+  EXPREGS[1]=~0;\r
+  EXPREGS[2]=1;\r
+  EXPREGS[3]=3;\r
+  GenMMC3Power();\r
+  SetWriteHandler(0x8000,0xFFFF,M199Write);\r
+}\r
+\r
+void Mapper199_Init(CartInfo *info)\r
+{\r
+  int CHRRAMSize=1024*8;\r
+  GenMMC3_Init(info, 512, 256, 8, info->battery);\r
+  cwrap=M199CW;\r
+  pwrap=M199PW;\r
+  mwrap=M199MW;\r
+  info->Power=M199Power;\r
+  CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize);\r
+  SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1);\r
+  AddExState(CHRRAM, CHRRAMSize, 0, "CHRR");\r
+  AddExState(EXPREGS, 4, 0, "EXPR");\r
+}\r
index 9ccf8e7..3bbb34d 100644 (file)
@@ -1,83 +1,83 @@
-/* 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");
-}
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2005 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+#include "mmc3.h"\r
+\r
+static uint8 lut[256]={\r
+  0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x59, 0x49, 0x19, 0x09, 0x59, 0x49, 0x19, 0x09,\r
+  0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x51, 0x41, 0x11, 0x01, 0x51, 0x41, 0x11, 0x01,\r
+  0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x59, 0x49, 0x19, 0x09, 0x59, 0x49, 0x19, 0x09,\r
+  0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x51, 0x41, 0x11, 0x01, 0x51, 0x41, 0x11, 0x01,\r
+  0x00, 0x10, 0x40, 0x50, 0x00, 0x10, 0x40, 0x50,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
+  0x08, 0x18, 0x48, 0x58, 0x08, 0x18, 0x48, 0x58,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
+  0x00, 0x10, 0x40, 0x50, 0x00, 0x10, 0x40, 0x50,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
+  0x08, 0x18, 0x48, 0x58, 0x08, 0x18, 0x48, 0x58,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
+  0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x58, 0x48, 0x18, 0x08, 0x58, 0x48, 0x18, 0x08,\r
+  0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x50, 0x40, 0x10, 0x00, 0x50, 0x40, 0x10, 0x00,\r
+  0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x58, 0x48, 0x18, 0x08, 0x58, 0x48, 0x18, 0x08,\r
+  0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x50, 0x40, 0x10, 0x00, 0x50, 0x40, 0x10, 0x00,\r
+  0x01, 0x11, 0x41, 0x51, 0x01, 0x11, 0x41, 0x51,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
+  0x09, 0x19, 0x49, 0x59, 0x09, 0x19, 0x49, 0x59,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
+  0x01, 0x11, 0x41, 0x51, 0x01, 0x11, 0x41, 0x51,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
+  0x09, 0x19, 0x49, 0x59, 0x09, 0x19, 0x49, 0x59,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\r
+};\r
+\r
+static void M208PW(uint32 A, uint8 V)\r
+{\r
+  setprg32(0x8000,EXPREGS[5]);\r
+}\r
+\r
+static DECLFW(M208Write)\r
+{\r
+  EXPREGS[5]=(V&0x1)|((V>>3)&0x2);\r
+  FixMMC3PRG(MMC3_cmd);\r
+}\r
+\r
+static DECLFW(M208ProtWrite)\r
+{\r
+  if(A<=0x57FF)\r
+    EXPREGS[4]=V;\r
+  else\r
+    EXPREGS[(A&0x03)]=V^lut[EXPREGS[4]];\r
+}\r
+\r
+static DECLFR(M208ProtRead)\r
+{\r
+  return(EXPREGS[(A&0x3)]);\r
+}\r
+\r
+static void M208Power(void)\r
+{\r
+  EXPREGS[5]=3;\r
+  GenMMC3Power();\r
+  SetWriteHandler(0x4800,0x4FFF,M208Write);\r
+  SetWriteHandler(0x5000,0x5fff,M208ProtWrite);\r
+  SetReadHandler(0x5800,0x5FFF,M208ProtRead);\r
+  SetReadHandler(0x8000,0xffff,CartBR);\r
+}\r
+\r
+void Mapper208_Init(CartInfo *info)\r
+{\r
+  GenMMC3_Init(info, 128, 256, 0, 0);\r
+  pwrap=M208PW;\r
+  info->Power=M208Power;\r
+  AddExState(EXPREGS, 6, 0, "EXPR");\r
+}\r
index fd3cc8a..e230751 100644 (file)
-/* 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);
-}
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2005 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ * (VRC4 mapper)\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 IRQCount;\r
+static uint8 IRQa;\r
+static uint8 prg_reg[2];\r
+static uint8 chr_reg[8];\r
+static uint8 mirr;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&IRQCount, 1, "IRQC"},\r
+  {&IRQa, 1, "IRQA"},\r
+  {prg_reg, 2, "PRG"},\r
+  {chr_reg, 8, "CHR"},\r
+  {&mirr, 1, "MIRR"},\r
+  {0}\r
+};\r
+\r
+static void M222IRQ(void)\r
+{\r
+  if(IRQa)\r
+  {\r
+    IRQCount++;\r
+    if(IRQCount>=238)\r
+    {\r
+      X6502_IRQBegin(FCEU_IQEXT);\r
+//      IRQa=0;\r
+    }\r
+  }\r
+}\r
+\r
+static void Sync(void)\r
+{\r
+  int i;\r
+  setprg8(0x8000,prg_reg[0]);\r
+  setprg8(0xA000,prg_reg[1]);\r
+  for(i=0; i<8; i++)\r
+     setchr1(i<<10,chr_reg[i]);\r
+  setmirror(mirr^1);\r
+}\r
+\r
+static DECLFW(M222Write)\r
+{\r
+  switch(A&0xF003)\r
+  {\r
+    case 0x8000: prg_reg[0]=V; break;\r
+    case 0x9000: mirr=V&1;     break;\r
+    case 0xA000: prg_reg[1]=V; break;\r
+    case 0xB000: chr_reg[0]=V; break;\r
+    case 0xB002: chr_reg[1]=V; break;\r
+    case 0xC000: chr_reg[2]=V; break;\r
+    case 0xC002: chr_reg[3]=V; break;\r
+    case 0xD000: chr_reg[4]=V; break;\r
+    case 0xD002: chr_reg[5]=V; break;\r
+    case 0xE000: chr_reg[6]=V; break;\r
+    case 0xE002: chr_reg[7]=V; break;\r
+//    case 0xF000: FCEU_printf("%04x:%02x %d\n",A,V,scanline); IRQa=V; if(!V)IRQPre=0; X6502_IRQEnd(FCEU_IQEXT); break;\r
+//  /  case 0xF001: FCEU_printf("%04x:%02x %d\n",A,V,scanline); IRQCount=V; break;\r
+//    case 0xF002: FCEU_printf("%04x:%02x %d\n",A,V,scanline); break;\r
+//    case 0xD001: IRQa=V; X6502_IRQEnd(FCEU_IQEXT); FCEU_printf("%04x:%02x %d\n",A,V,scanline); break;\r
+//    case 0xC001: IRQPre=16; FCEU_printf("%04x:%02x %d\n",A,V,scanline); break;\r
+    case 0xF000: IRQa=IRQCount=V; if(scanline<240) IRQCount-=8; else IRQCount+=4; X6502_IRQEnd(FCEU_IQEXT); break;\r
+  }\r
+  Sync();\r
+}\r
+\r
+static void M222Power(void)\r
+{\r
+  setprg16(0xC000,~0);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0xFFFF,M222Write);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper222_Init(CartInfo *info)\r
+{\r
+  info->Power=M222Power;\r
+  GameHBIRQHook=M222IRQ;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
diff --git a/boards/23.c b/boards/23.c
new file mode 100644 (file)
index 0000000..8760d50
--- /dev/null
@@ -0,0 +1,208 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2007 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 is23;\r
+static uint16 IRQCount;\r
+static uint8 IRQLatch,IRQa;\r
+static uint8 prgreg[2];\r
+static uint8 chrreg[8];\r
+static uint8 regcmd, irqcmd, mirr, big_bank;\r
+static uint16 acount=0;\r
+\r
+static uint8 *WRAM=NULL;\r
+static uint32 WRAMSIZE;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {prgreg, 2, "PRGREGS"},\r
+  {chrreg, 8, "CHRREGS"},\r
+  {&regcmd, 1, "REGCMD"},\r
+  {&irqcmd, 1, "IRQCMD"},\r
+  {&mirr, 1, "MIRR"},\r
+  {&big_bank, 1, "BIGB"},\r
+  {&IRQCount, 2, "IRCN"},\r
+  {&IRQLatch, 1, "IRQL"},\r
+  {&IRQa, 1, "IRQA"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  if(regcmd&2)\r
+  {\r
+    setprg8(0xC000,prgreg[0]|big_bank);\r
+    setprg8(0x8000,((~1)&0x1F)|big_bank);\r
+  }\r
+  else\r
+  {\r
+    setprg8(0x8000,prgreg[0]|big_bank);\r
+    setprg8(0xC000,((~1)&0x1F)|big_bank);\r
+  }\r
+  setprg8(0xA000,prgreg[1]|big_bank);\r
+  setprg8(0xE000,((~0)&0x1F)|big_bank);\r
+  if(UNIFchrrama)\r
+    setchr8(0);\r
+  else\r
+  {\r
+    uint8 i;\r
+    for(i=0; i<8; i++)\r
+       setchr1(i<<10, chrreg[i]);\r
+  }\r
+  switch(mirr&0x3)\r
+  {\r
+    case 0: setmirror(MI_V); break;\r
+    case 1: setmirror(MI_H); break;\r
+    case 2: setmirror(MI_0); break;\r
+    case 3: setmirror(MI_1); break;\r
+  }\r
+}\r
+\r
+static DECLFW(M23Write)\r
+{\r
+//  FCEU_printf("%04x:%04x\n",A,V);\r
+  A|=((A>>2)&0x3)|((A>>4)&0x3)|((A>>6)&0x3); // actually there is many-in-one mapper source, some pirate or\r
+                                             // licensed games use various address bits for registers\r
+  A&=0xF003;\r
+  if((A>=0xB000)&&(A<=0xE003))\r
+  {\r
+    if(UNIFchrrama)\r
+      big_bank=(V&8)<<2;                    // my personally many-in-one feature ;) just for support pirate cart 2-in-1\r
+    else\r
+    {    \r
+      uint16 i=((A>>1)&1)|((A-0xB000)>>11);\r
+      chrreg[i]&=(0xF0)>>((A&1)<<2);\r
+      chrreg[i]|=(V&0xF)<<((A&1)<<2);\r
+    }\r
+    Sync();\r
+  }\r
+  else\r
+    switch(A&0xF003)\r
+    {\r
+      case 0x8000: \r
+      case 0x8001: \r
+      case 0x8002: \r
+      case 0x8003: if(is23) \r
+                     prgreg[0]=V&0x1F; \r
+                   Sync(); \r
+                   break;\r
+      case 0xA000: \r
+      case 0xA001: \r
+      case 0xA002: \r
+      case 0xA003: if(is23) \r
+                     prgreg[1]=V&0x1F; \r
+                   else\r
+                   {\r
+                     prgreg[0]=(V<<1)&0x1F;\r
+                     prgreg[1]=((V<<1)&0x1F)|1;\r
+                   }\r
+                   Sync();\r
+                   break;\r
+      case 0x9000:\r
+      case 0x9001: if(V!=0xFF) mirr=V; Sync(); break;\r
+      case 0x9002: \r
+      case 0x9003: regcmd=V; Sync(); break;\r
+      case 0xF000: X6502_IRQEnd(FCEU_IQEXT); IRQLatch&=0xF0; IRQLatch|=V&0xF; break;\r
+      case 0xF001: X6502_IRQEnd(FCEU_IQEXT); IRQLatch&=0x0F; IRQLatch|=V<<4; break;\r
+      case 0xF002: X6502_IRQEnd(FCEU_IQEXT); acount=0; IRQCount=IRQLatch; IRQa=V&2; irqcmd=V&1; break;\r
+      case 0xF003: X6502_IRQEnd(FCEU_IQEXT); IRQa=irqcmd; break;\r
+    }\r
+}\r
+\r
+static void M23Power(void)\r
+{\r
+  big_bank=0x20;  \r
+  Sync();\r
+  setprg8r(0x10,0x6000,0);              // another many-in-one code, WRAM actually contain only WaiWaiWorld game\r
+  SetReadHandler(0x6000,0x7FFF,CartBR);\r
+  SetWriteHandler(0x6000,0x7FFF,CartBW);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0xFFFF,M23Write);\r
+}\r
+\r
+static void M23Reset(void)\r
+{\r
+}\r
+\r
+void M23IRQHook(int a)\r
+{\r
+  #define LCYCS 341\r
+  if(IRQa)\r
+  {\r
+    acount+=a*3;\r
+    if(acount>=LCYCS)\r
+    {\r
+      while(acount>=LCYCS)\r
+      {\r
+        acount-=LCYCS;\r
+        IRQCount++;\r
+        if(IRQCount&0x100) \r
+        {\r
+          X6502_IRQBegin(FCEU_IQEXT);\r
+          IRQCount=IRQLatch;\r
+        }\r
+      }\r
+    }\r
+  }\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+static void M23Close(void)\r
+{\r
+  if(WRAM)\r
+    FCEU_gfree(WRAM);\r
+}\r
+\r
+void Mapper23_Init(CartInfo *info)\r
+{\r
+  is23=1;\r
+  info->Power=M23Power;\r
+  info->Close=M23Close;\r
+  MapIRQHook=M23IRQHook;\r
+  GameStateRestore=StateRestore;\r
+\r
+  WRAMSIZE=8192;\r
+  WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);\r
+  SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);\r
+  AddExState(WRAM, WRAMSIZE, 0, "WRAM");\r
+\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
+\r
+void UNLT230_Init(CartInfo *info)\r
+{\r
+  is23=0;\r
+  info->Power=M23Power;\r
+  info->Close=M23Close;\r
+  MapIRQHook=M23IRQHook;\r
+  GameStateRestore=StateRestore;\r
+\r
+  WRAMSIZE=8192;\r
+  WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);\r
+  SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);\r
+  AddExState(WRAM, WRAMSIZE, 0, "WRAM");\r
+\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
index 34bbc0f..4cae946 100644 (file)
@@ -1,70 +1,70 @@
-/* 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);
-}
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2005 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint16 cmdreg;\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&cmdreg, 2, "CMDREG"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  if(cmdreg&0x400)\r
+    setmirror(MI_0);\r
+  else\r
+    setmirror(((cmdreg>>13)&1)^1);\r
+  if(cmdreg&0x800)\r
+  {\r
+    setprg16(0x8000,((cmdreg&0x300)>>3)|((cmdreg&0x1F)<<1)|((cmdreg>>12)&1));\r
+    setprg16(0xC000,((cmdreg&0x300)>>3)|((cmdreg&0x1F)<<1)|((cmdreg>>12)&1));\r
+  }\r
+  else\r
+    setprg32(0x8000,((cmdreg&0x300)>>4)|(cmdreg&0x1F));\r
+}\r
+\r
+static DECLFW(M235Write)\r
+{\r
+  cmdreg=A;\r
+  Sync();\r
+}\r
+\r
+static void M235Power(void)\r
+{\r
+  setchr8(0);\r
+  SetWriteHandler(0x8000,0xFFFF,M235Write);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  cmdreg=0;\r
+  Sync();\r
+}\r
+\r
+static void M235Restore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper235_Init(CartInfo *info)\r
+{\r
+  info->Power=M235Power;\r
+  GameStateRestore=M235Restore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
diff --git a/boards/253.c b/boards/253.c
new file mode 100644 (file)
index 0000000..6e3b569
--- /dev/null
@@ -0,0 +1,175 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2009 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 chrlo[8], chrhi[8], prg[2], mirr, vlock;\r
+static int32 IRQa, IRQCount, IRQLatch, IRQClock; \r
+static uint8 *WRAM=NULL;\r
+static uint32 WRAMSIZE;\r
+static uint8 *CHRRAM=NULL;\r
+static uint32 CHRRAMSIZE;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {chrlo, 8, "CHRLO"},\r
+  {chrhi, 8, "CHRHI"},\r
+  {prg, 2, "PRGR"},\r
+  {&mirr, 1, "MIRR"},\r
+  {&vlock, 1, "VLOCK"},\r
+  {&IRQa, 4, "IRQA"},\r
+  {&IRQCount, 4, "IRQC"},\r
+  {&IRQLatch, 4, "IRQL"},\r
+  {&IRQClock, 4, "IRQK"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  uint8 i;\r
+  setprg8r(0x10,0x6000,0);\r
+  setprg8(0x8000,prg[0]);\r
+  setprg8(0xa000,prg[1]);\r
+  setprg8(0xc000,~1);\r
+  setprg8(0xe000,~0);\r
+  for(i=0; i<8; i++)\r
+  {\r
+    uint32 chr = chrlo[i]|(chrhi[i]<<8);\r
+    if(chrlo[i]==0xc8)\r
+    {\r
+      vlock = 0;\r
+      continue;\r
+    }\r
+    else if(chrlo[i]==0x88)\r
+    {\r
+      vlock = 1;\r
+      continue;\r
+    }\r
+    if(((chrlo[i]==4)||(chrlo[i]==5))&&!vlock)\r
+      setchr1r(0x10,i<<10,chr&1);\r
+    else\r
+      setchr1(i<<10,chr);\r
+  }\r
+  switch(mirr)\r
+  {\r
+    case 0: setmirror(MI_V); break;\r
+    case 1: setmirror(MI_H); break;\r
+    case 2: setmirror(MI_0); break;\r
+    case 3: setmirror(MI_1); break;\r
+  }\r
+}\r
+\r
+static DECLFW(M253Write)\r
+{\r
+  if((A>=0xB000)&&(A<=0xE00C))\r
+  {\r
+    uint8 ind=((((A&8)|(A>>8))>>3)+2)&7;\r
+    uint8 sar=A&4;\r
+    chrlo[ind]=(chrlo[ind]&(0xF0>>sar))|((V&0x0F)<<sar);\r
+    if(A&4)\r
+      chrhi[ind]=V>>4;\r
+    Sync();\r
+  }\r
+  else\r
+   switch(A)\r
+    {\r
+      case 0x8010: prg[0]=V; Sync(); break;\r
+      case 0xA010: prg[1]=V; Sync(); break;\r
+      case 0x9400: mirr=V&3; Sync(); break;\r
+      case 0xF000: IRQLatch = (IRQLatch & 0xF0) | (V & 0x0F); break;\r
+      case 0xF004: IRQLatch = (IRQLatch & 0x0F) | (V << 4); break;\r
+      case 0xF008:\r
+        IRQa = V&3;\r
+        if(IRQa&2)\r
+        {\r
+          IRQCount = IRQLatch;\r
+          IRQClock = 0;\r
+        }\r
+        X6502_IRQEnd(FCEU_IQEXT);\r
+        break;\r
+    }\r
+}\r
+\r
+static void M253Power(void)\r
+{\r
+  Sync();\r
+  SetReadHandler(0x6000,0x7FFF,CartBR);\r
+  SetWriteHandler(0x6000,0x7FFF,CartBW);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0xFFFF,M253Write);\r
+}\r
+\r
+static void M253Close(void)\r
+{\r
+  if(WRAM)\r
+    FCEU_gfree(WRAM);\r
+  if(CHRRAM)\r
+    FCEU_gfree(CHRRAM);\r
+  WRAM=CHRRAM=NULL;\r
+}\r
+\r
+static void M253IRQ(int cycles)\r
+{\r
+  if(IRQa&2) \r
+  {\r
+    if((IRQClock+=cycles)>=0x72) \r
+    {\r
+      IRQClock -= 0x72;\r
+      if(IRQCount==0xFF)  \r
+      {\r
+        IRQCount = IRQLatch;\r
+        IRQa = IRQa|((IRQa&1)<<1);\r
+        X6502_IRQBegin(FCEU_IQEXT);\r
+      }\r
+      else \r
+        IRQCount++;\r
+    }\r
+  }\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper253_Init(CartInfo *info)\r
+{\r
+  info->Power=M253Power;\r
+  info->Close=M253Close;\r
+  MapIRQHook=M253IRQ;\r
+  GameStateRestore=StateRestore;\r
+\r
+  CHRRAMSIZE=4096;\r
+  CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSIZE);\r
+  SetupCartCHRMapping(0x10,CHRRAM,CHRRAMSIZE,1);\r
+  AddExState(CHRRAM, CHRRAMSIZE, 0, "CRAM");\r
+\r
+  WRAMSIZE=8192;\r
+  WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);\r
+  SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);\r
+  AddExState(WRAM, WRAMSIZE, 0, "WRAM");\r
+  if(info->battery)\r
+  {\r
+    info->SaveGame[0]=WRAM;\r
+    info->SaveGameLen[0]=WRAMSIZE;\r
+  }\r
+\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
diff --git a/boards/3d-block.c b/boards/3d-block.c
new file mode 100644 (file)
index 0000000..24572a4
--- /dev/null
@@ -0,0 +1,110 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2007 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg[4], IRQa;\r
+static int16 IRQCount, IRQPause;\r
+\r
+static int16 Count = 0x0000;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {reg, 4, "REGS"},\r
+  {&IRQa, 1, "IRQA"},\r
+  {&IRQCount, 2, "IRQC"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setprg32(0x8000,0);\r
+  setchr8(0);\r
+}\r
+\r
+//#define Count 0x1800\r
+#define Pause 0x010\r
+\r
+static DECLFW(UNL3DBlockWrite)\r
+{\r
+  switch(A)\r
+  {\r
+//4800 32\r
+//4900 37\r
+//4a00 01\r
+//4e00 18\r
+    case 0x4800: reg[0]=V; break;\r
+    case 0x4900: reg[1]=V; break;\r
+    case 0x4a00: reg[2]=V; break;\r
+    case 0x4e00: reg[3]=V; IRQCount=Count; IRQPause=Pause; IRQa=1; X6502_IRQEnd(FCEU_IQEXT); break;\r
+  } \r
+}\r
+\r
+static void UNL3DBlockPower(void)\r
+{\r
+  Sync();\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x4800,0x4E00,UNL3DBlockWrite);\r
+}\r
+\r
+static void UNL3DBlockReset(void)\r
+{\r
+  Count+=0x10;\r
+  FCEU_printf("Count=%04x\n",Count);\r
+}\r
+\r
+static void UNL3DBlockIRQHook(int a)\r
+{\r
+  if(IRQa)\r
+  {\r
+    if(IRQCount>0)\r
+    {\r
+      IRQCount-=a;\r
+    }\r
+    else\r
+    {\r
+      if(IRQPause>0)\r
+      {\r
+        IRQPause-=a;\r
+        X6502_IRQBegin(FCEU_IQEXT);\r
+      }\r
+      else\r
+      {\r
+        IRQCount=Count; \r
+        IRQPause=Pause;\r
+        X6502_IRQEnd(FCEU_IQEXT);\r
+      }\r
+    }\r
+  }\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void UNL3DBlock_Init(CartInfo *info)\r
+{\r
+  info->Power=UNL3DBlockPower;\r
+  info->Reset=UNL3DBlockReset;\r
+  MapIRQHook=UNL3DBlockIRQHook;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
diff --git a/boards/411120-c.c b/boards/411120-c.c
new file mode 100644 (file)
index 0000000..479a9bf
--- /dev/null
@@ -0,0 +1,70 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2008 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+// actually cart ID is 811120-C, sorry ;) K-3094 - another ID\r
+\r
+#include "mapinc.h"\r
+#include "mmc3.h"\r
+\r
+static uint8 reset_flag = 0;\r
+\r
+static void BMC411120CCW(uint32 A, uint8 V)\r
+{\r
+    setchr1(A,V|((EXPREGS[0]&3)<<7));\r
+}\r
+\r
+static void BMC411120CPW(uint32 A, uint8 V)\r
+{\r
+    if(EXPREGS[0]&(8|reset_flag))\r
+      setprg32(0x8000,((EXPREGS[0]>>4)&3)|(0x0C));\r
+    else\r
+      setprg8(A,(V&0x0F)|((EXPREGS[0]&3)<<4));\r
+}\r
+\r
+static DECLFW(BMC411120CLoWrite)\r
+{\r
+  EXPREGS[0] = A;\r
+  FixMMC3PRG(MMC3_cmd);\r
+  FixMMC3CHR(MMC3_cmd);\r
+}\r
+\r
+static void BMC411120CReset(void)\r
+{\r
+  EXPREGS[0]=0;\r
+  reset_flag ^=4;\r
+  MMC3RegReset();\r
+}\r
+\r
+static void BMC411120CPower(void)\r
+{\r
+  EXPREGS[0] = 0;\r
+  GenMMC3Power();\r
+  SetWriteHandler(0x6000,0x7FFF,BMC411120CLoWrite);\r
+}\r
+\r
+void BMC411120C_Init(CartInfo *info)\r
+{\r
+  GenMMC3_Init(info, 128, 128, 8, 0);\r
+  pwrap=BMC411120CPW;\r
+  cwrap=BMC411120CCW;\r
+  info->Power=BMC411120CPower;\r
+  info->Reset=BMC411120CReset;\r
+  AddExState(EXPREGS, 1, 0, "EXPR");\r
+}\r
diff --git a/boards/43.c b/boards/43.c
new file mode 100644 (file)
index 0000000..ee12dec
--- /dev/null
@@ -0,0 +1,94 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2006 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+//ccording to nestopia, BTL_SMB2_C, otherwise known as UNL-SMB2J\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg;\r
+static uint8 IRQa;\r
+static uint32 IRQCount;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&IRQCount, 4, "IRQC"},\r
+  {&IRQa, 1, "IRQA"},\r
+  {&reg, 1, "REG"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setprg4(0x5000,16);  \r
+  setprg8(0x6000,2);\r
+  setprg8(0x8000,1);\r
+  setprg8(0xa000,0);\r
+  setprg8(0xc000,reg);\r
+  setprg8(0xe000,9);\r
+  setchr8(0);\r
+}\r
+\r
+static DECLFW(M43Write)\r
+{\r
+  int transo[8]={4,3,4,4,4,7,5,6};\r
+  switch(A&0xf1ff)\r
+  {\r
+    case 0x4022: reg=transo[V&7]; Sync(); break;\r
+    case 0x8122: IRQa=V&1; IRQCount=0; break;\r
+  }\r
+}\r
+\r
+static void M43Power(void)\r
+{\r
+  reg=0;\r
+  Sync();\r
+//  SetReadHandler(0x5000,0x5fff,CartBR);\r
+  SetReadHandler(0x5000,0xffff,CartBR);\r
+  SetWriteHandler(0x4020,0xffff,M43Write);\r
+}\r
+\r
+static void M43Reset(void)\r
+{\r
+}\r
+\r
+static void M43IRQHook(int a)\r
+{\r
+ IRQCount+=a;\r
+ if(IRQa)\r
+  if(IRQCount>=4096)\r
+  {\r
+   IRQa=0;\r
+   X6502_IRQBegin(FCEU_IQEXT);\r
+  }\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper43_Init(CartInfo *info)\r
+{\r
+  info->Reset=M43Reset;\r
+  info->Power=M43Power;\r
+  MapIRQHook=M43IRQHook;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
index 693677d..ba5de0b 100644 (file)
@@ -1,93 +1,92 @@
-/* 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);
-}
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2005 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 prg_reg;\r
+static uint8 chr_reg;\r
+static uint8 hrd_flag;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&hrd_flag, 1, "DIPSW"},\r
+  {&prg_reg, 1, "PRG"},\r
+  {&chr_reg, 1, "CHR"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  if(prg_reg&0x80)\r
+    setprg32(0x8000,prg_reg>>6);\r
+  else\r
+  {\r
+    setprg16(0x8000,(prg_reg>>5)&3);\r
+    setprg16(0xC000,(prg_reg>>5)&3);\r
+  }\r
+  setmirror((prg_reg&8)>>3);\r
+  setchr8((chr_reg&3)|(prg_reg&7)|((prg_reg&0x10)>>1));\r
+}\r
+\r
+static DECLFR(M57Read)\r
+{\r
+  return hrd_flag;\r
+}\r
+\r
+static DECLFW(M57Write)\r
+{\r
+  if((A&0x8800)==0x8800)\r
+    prg_reg=V;\r
+  else\r
+    chr_reg=V;\r
+  Sync();\r
+}\r
+\r
+static void M57Power(void)\r
+{\r
+  prg_reg=0;\r
+  chr_reg=0;\r
+  hrd_flag=0;\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0xFFFF,M57Write);\r
+  SetReadHandler(0x6000,0x6000,M57Read);\r
+  Sync();\r
+}\r
+\r
+static void M57Reset()\r
+{\r
+  hrd_flag++;\r
+  hrd_flag&=3;\r
+  FCEU_printf("Select Register = %02x\n",hrd_flag);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper57_Init(CartInfo *info)\r
+{\r
+  info->Power=M57Power;\r
+  info->Reset=M57Reset;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
similarity index 54%
rename from boards/cc21.c
rename to boards/603-5052.c
index 0e2cbe6..43b4e0a 100644 (file)
@@ -1,56 +1,48 @@
-/* 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");
-}
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2005 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+#include "mmc3.h"\r
+\r
+static uint8 lut[4] = { 0x00, 0x02, 0x02, 0x03 };\r
+\r
+static DECLFW(UNL6035052ProtWrite)\r
+{\r
+  EXPREGS[0]=lut[V&3];  \r
+}\r
+\r
+static DECLFR(UNL6035052ProtRead)\r
+{\r
+  return EXPREGS[0];\r
+}\r
+\r
+static void UNL6035052Power(void)\r
+{\r
+  GenMMC3Power();\r
+  SetWriteHandler(0x4020,0x7FFF,UNL6035052ProtWrite);\r
+  SetReadHandler(0x4020,0x7FFF,UNL6035052ProtRead);\r
+}\r
+\r
+void UNL6035052_Init(CartInfo *info)\r
+{\r
+  GenMMC3_Init(info, 128, 256, 0, 0);\r
+  info->Power=UNL6035052Power;\r
+  AddExState(EXPREGS, 6, 0, "EXPR");\r
+}\r
diff --git a/boards/68.c b/boards/68.c
new file mode 100644 (file)
index 0000000..6a9420c
--- /dev/null
@@ -0,0 +1,178 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2006 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 chr_reg[4];\r
+static uint8 kogame, prg_reg, nt1, nt2, mirr;\r
+\r
+static uint8 *WRAM=NULL;\r
+static uint32 WRAMSIZE, count;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&nt1, 1, "NT1"},\r
+  {&nt2, 1, "NT2"},\r
+  {&mirr, 1, "MIRR"},\r
+  {&prg_reg, 1, "PRG"},\r
+  {&kogame, 1, "KOGAME"},\r
+  {&count, 4, "COUNT"},\r
+  {chr_reg, 4, "CHR"},\r
+  {0}\r
+};\r
+\r
+static void M68NTfix(void)\r
+{\r
+  if((!UNIFchrrama)&&(mirr&0x10))\r
+  {\r
+    PPUNTARAM = 0;\r
+    switch(mirr&3)\r
+    {\r
+     case 0: vnapage[0]=vnapage[2]=CHRptr[0]+(((nt1|128)&CHRmask1[0])<<10);\r
+             vnapage[1]=vnapage[3]=CHRptr[0]+(((nt2|128)&CHRmask1[0])<<10);\r
+             break;\r
+     case 1: vnapage[0]=vnapage[1]=CHRptr[0]+(((nt1|128)&CHRmask1[0])<<10);\r
+             vnapage[2]=vnapage[3]=CHRptr[0]+(((nt2|128)&CHRmask1[0])<<10);\r
+             break;\r
+     case 2: vnapage[0]=vnapage[1]=vnapage[2]=vnapage[3]=CHRptr[0]+(((nt1|128)&CHRmask1[0])<<10);\r
+             break;\r
+     case 3: vnapage[0]=vnapage[1]=vnapage[2]=vnapage[3]=CHRptr[0]+(((nt2|128)&CHRmask1[0])<<10);\r
+             break;\r
+    }\r
+  }\r
+  else\r
+    switch(mirr&3)\r
+    {\r
+      case 0: setmirror(MI_V); break;\r
+      case 1: setmirror(MI_H); break;\r
+      case 2: setmirror(MI_0); break;\r
+      case 3: setmirror(MI_1); break;\r
+    }\r
+}\r
+\r
+static void Sync(void)\r
+{\r
+  setchr2(0x0000,chr_reg[0]);\r
+  setchr2(0x0800,chr_reg[1]);\r
+  setchr2(0x1000,chr_reg[2]);\r
+  setchr2(0x1800,chr_reg[3]);\r
+  setprg8r(0x10,0x6000,0);\r
+  setprg16r((PRGptr[1])?kogame:0,0x8000,prg_reg);\r
+  setprg16(0xC000,~0);\r
+}\r
+\r
+static DECLFR(M68Read)\r
+{\r
+  if(!(kogame&8))\r
+  {\r
+    count++;\r
+    if(count==1784)\r
+      setprg16r(0,0x8000,prg_reg);\r
+  }\r
+  return CartBR(A);\r
+}\r
+\r
+static DECLFW(M68WriteLo)\r
+{\r
+  if(!V)\r
+  { \r
+    count = 0;\r
+    setprg16r((PRGptr[1])?kogame:0,0x8000,prg_reg);\r
+  }\r
+}\r
+\r
+static DECLFW(M68WriteCHR)\r
+{\r
+  chr_reg[(A>>12)&3]=V;\r
+  Sync();\r
+}\r
+\r
+static DECLFW(M68WriteNT1)\r
+{\r
+  nt1 = V;            \r
+  M68NTfix();\r
+}\r
+\r
+static DECLFW(M68WriteNT2)\r
+{\r
+  nt2 = V;            \r
+  M68NTfix();\r
+}\r
+\r
+static DECLFW(M68WriteMIR)\r
+{\r
+  mirr = V;\r
+  M68NTfix();\r
+}\r
+\r
+static DECLFW(M68WriteROM)\r
+{\r
+  prg_reg = V&7;\r
+  kogame = ((V>>3)&1)^1;\r
+  Sync();\r
+}\r
+\r
+static void M68Power(void)\r
+{\r
+  prg_reg = 0;\r
+  kogame = 0;\r
+  Sync();\r
+  M68NTfix();\r
+  SetReadHandler(0x6000,0x7FFF,CartBR);\r
+  SetReadHandler(0x8000,0xBFFF,M68Read);\r
+  SetReadHandler(0xC000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0xBFFF,M68WriteCHR);\r
+  SetWriteHandler(0xC000,0xCFFF,M68WriteNT1);\r
+  SetWriteHandler(0xD000,0xDFFF,M68WriteNT2);\r
+  SetWriteHandler(0xE000,0xEFFF,M68WriteMIR);\r
+  SetWriteHandler(0xF000,0xFFFF,M68WriteROM);\r
+  SetWriteHandler(0x6000,0x6000,M68WriteLo);\r
+  SetWriteHandler(0x6001,0x7FFF,CartBW);\r
+}\r
+\r
+static void M68Close(void)\r
+{\r
+  if(WRAM)\r
+    FCEU_gfree(WRAM);\r
+  WRAM=NULL;\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+  M68NTfix();\r
+}\r
+\r
+void Mapper68_Init(CartInfo *info)\r
+{\r
+  info->Power=M68Power;\r
+  info->Close=M68Close;\r
+  GameStateRestore=StateRestore;\r
+  WRAMSIZE=8192;\r
+  WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);\r
+  SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);\r
+  if(info->battery)\r
+  {\r
+    info->SaveGame[0]=WRAM;\r
+    info->SaveGameLen[0]=WRAMSIZE;\r
+  }\r
+  AddExState(WRAM, WRAMSIZE, 0, "WRAM");\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
index 2aa3f4e..1b23023 100644 (file)
@@ -1,80 +1,81 @@
-/* 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);
-}
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2005 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint16 cmdreg;\r
+static uint8 invalid_data;\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&invalid_data, 1, "INVD"},  \r
+  {&cmdreg, 2, "CMDREG"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setprg16r((cmdreg&0x060)>>5,0x8000,(cmdreg&0x01C)>>2);\r
+  setprg16r((cmdreg&0x060)>>5,0xC000,(cmdreg&0x200)?(~0):0);\r
+  setmirror(((cmdreg&2)>>1)^1);\r
+}\r
+\r
+static DECLFR(UNL8157Read)\r
+{\r
+  if(invalid_data&&cmdreg&0x100)\r
+    return 0xFF;\r
+  else\r
+    return CartBR(A);\r
+}\r
+\r
+static DECLFW(UNL8157Write)\r
+{\r
+  cmdreg=A;\r
+  Sync();\r
+}\r
+\r
+static void UNL8157Power(void)\r
+{\r
+  setchr8(0);\r
+  SetWriteHandler(0x8000,0xFFFF,UNL8157Write);\r
+  SetReadHandler(0x8000,0xFFFF,UNL8157Read);\r
+  cmdreg=0x200;\r
+  invalid_data=1;\r
+  Sync();\r
+}\r
+\r
+static void UNL8157Reset(void)\r
+{\r
+  cmdreg=0;\r
+  invalid_data^=1;\r
+  Sync();\r
+}\r
+\r
+static void UNL8157Restore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void UNL8157_Init(CartInfo *info)\r
+{\r
+  info->Power=UNL8157Power;\r
+  info->Reset=UNL8157Reset;\r
+  GameStateRestore=UNL8157Restore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
index 5b4e2df..0415338 100644 (file)
-/* 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");
-}
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2005-2011 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ *\r
+ * Super Game (Sugar Softec) protected mapper\r
+ * Pocahontas 2 (Unl) [U][!], etc.\r
+ * TODO: 9in1 LION KING HANGS!\r
+ */\r
+\r
+#include "mapinc.h"\r
+#include "mmc3.h"\r
+\r
+static uint8 cmdin;\r
+\r
+static uint8 regperm[8][8] = \r
+  {\r
+    {0, 1, 2, 3, 4, 5, 6, 7},\r
+    {0, 2, 6, 1, 7, 3, 4, 5},\r
+    {0, 5, 4, 1, 7, 2, 6, 3}, // unused\r
+    {0, 6, 3, 7, 5, 2, 4, 1},\r
+    {0, 2, 5, 3, 6, 1, 7, 4},\r
+    {0, 1, 2, 3, 4, 5, 6, 7}, // empty\r
+    {0, 1, 2, 3, 4, 5, 6, 7}, // empty\r
+    {0, 1, 2, 3, 4, 5, 6, 7}, // empty\r
+  };\r
+\r
+static uint8 adrperm[8][8] = \r
+  {\r
+    {0, 1, 2, 3, 4, 5, 6, 7},\r
+    {3, 2, 0, 4, 1, 5, 6, 7},\r
+    {0, 1, 2, 3, 4, 5, 6, 7}, // unused\r
+    {5, 0, 1, 2, 3, 7, 6, 4},\r
+    {3, 1, 0, 5, 2, 4, 6, 7},\r
+    {0, 1, 2, 3, 4, 5, 6, 7}, // empty\r
+    {0, 1, 2, 3, 4, 5, 6, 7}, // empty\r
+    {0, 1, 2, 3, 4, 5, 6, 7}, // empty\r
+  };\r
+\r
+static void UNL8237CW(uint32 A, uint8 V)\r
+{\r
+  if(EXPREGS[0]&0x40)\r
+    setchr1(A,((EXPREGS[1]&0xc)<<6)|(V&0x7F)|((EXPREGS[1]&0x20)<<2));\r
+  else\r
+    setchr1(A,((EXPREGS[1]&0xc)<<6)|V);\r
+}\r
+\r
+static void UNL8237PW(uint32 A, uint8 V)\r
+{\r
+  if(EXPREGS[0]&0x40)\r
+  {\r
+    uint8 sbank = (EXPREGS[1]&0x10);\r
+    if(EXPREGS[0]&0x80)\r
+    {\r
+      uint8 bank = ((EXPREGS[1]&3)<<4)|(EXPREGS[0]&0x7)|(sbank>>1);\r
+      if(EXPREGS[0]&0x20)\r
+        setprg32(0x8000,bank>>1);\r
+      else\r
+      {\r
+        setprg16(0x8000,bank);\r
+        setprg16(0xC000,bank);\r
+      }\r
+    }\r
+    else\r
+      setprg8(A,((EXPREGS[1]&3)<<5)|(V&0x0F)|sbank);\r
+  }\r
+  else\r
+  {\r
+    if(EXPREGS[0]&0x80)\r
+    {\r
+      uint8 bank = ((EXPREGS[1]&3)<<4)|(EXPREGS[0]&0xF);\r
+      if(EXPREGS[0]&0x20)\r
+        setprg32(0x8000,bank>>1);\r
+      else\r
+      {\r
+        setprg16(0x8000,bank);\r
+        setprg16(0xC000,bank);\r
+      }\r
+    }\r
+    else\r
+      setprg8(A,((EXPREGS[1]&3)<<5)|(V&0x1F));\r
+  }\r
+}\r
+\r
+static void UNL8237ACW(uint32 A, uint8 V)\r
+{\r
+  if(EXPREGS[0]&0x40)\r
+    setchr1(A,((EXPREGS[1]&0xE)<<7)|(V&0x7F)|((EXPREGS[1]&0x20)<<2));\r
+  else\r
+    setchr1(A,((EXPREGS[1]&0xE)<<7)|V);\r
+}\r
+\r
+static void UNL8237APW(uint32 A, uint8 V)\r
+{\r
+  if(EXPREGS[0]&0x40)\r
+  {\r
+    uint8 sbank = (EXPREGS[1]&0x10);\r
+    if(EXPREGS[0]&0x80)\r
+    {\r
+      uint8 bank = ((EXPREGS[1]&3)<<4)|((EXPREGS[1]&8)<<3)|(EXPREGS[0]&0x7)|(sbank>>1);\r
+      if(EXPREGS[0]&0x20)\r
+        setprg32(0x8000,bank>>1);\r
+      else\r
+      {\r
+        setprg16(0x8000,bank);\r
+        setprg16(0xC000,bank);\r
+      }\r
+    }\r
+    else\r
+      setprg8(A,((EXPREGS[1]&3)<<5)|((EXPREGS[1]&8)<<4)|(V&0x0F)|sbank);\r
+  }\r
+  else\r
+  {\r
+    if(EXPREGS[0]&0x80)\r
+    {\r
+      uint8 bank = ((EXPREGS[1]&3)<<4)|((EXPREGS[1]&8)<<3)|(EXPREGS[0]&0xF);\r
+      if(EXPREGS[0]&0x20)\r
+        setprg32(0x8000,bank>>1);\r
+      else\r
+      {\r
+        setprg16(0x8000,bank);\r
+        setprg16(0xC000,bank);\r
+      }\r
+    }\r
+    else\r
+      setprg8(A,((EXPREGS[1]&3)<<5)|((EXPREGS[1]&8)<<4)|(V&0x1F));\r
+  }\r
+}\r
+static DECLFW(UNL8237Write)\r
+{\r
+  uint8 dat = V;\r
+  uint8 adr = adrperm[EXPREGS[2]][((A>>12)&6)|(A&1)];\r
+  uint16 addr = (adr & 1)|((adr & 6)<<12)|0x8000;\r
+  if(adr < 4)\r
+  {\r
+    if(!adr)\r
+      dat = (dat & 0xC0)|(regperm[EXPREGS[2]][dat & 7]);\r
+    MMC3_CMDWrite(addr,dat);\r
+  }\r
+  else \r
+    MMC3_IRQWrite(addr,dat);\r
+}\r
+\r
+static DECLFW(UNL8237ExWrite)\r
+{\r
+  switch(A)\r
+  {\r
+    case 0x5000: EXPREGS[0]=V; FixMMC3PRG(MMC3_cmd); break;\r
+    case 0x5001: EXPREGS[1]=V; FixMMC3PRG(MMC3_cmd); FixMMC3CHR(MMC3_cmd); break;\r
+    case 0x5007: EXPREGS[2]=V; break;\r
+  }\r
+}\r
+\r
+static void UNL8237Power(void)\r
+{\r
+  EXPREGS[0]=EXPREGS[2]=0;\r
+  EXPREGS[1]=3;\r
+  GenMMC3Power();\r
+  SetWriteHandler(0x8000,0xFFFF,UNL8237Write);\r
+  SetWriteHandler(0x5000,0x7FFF,UNL8237ExWrite);\r
+}\r
+\r
+void UNL8237_Init(CartInfo *info)\r
+{\r
+  GenMMC3_Init(info, 256, 256, 0, 0);\r
+  cwrap=UNL8237CW;\r
+  pwrap=UNL8237PW;\r
+  info->Power=UNL8237Power;\r
+  AddExState(EXPREGS, 3, 0, "EXPR");\r
+  AddExState(&cmdin, 1, 0, "CMDIN");\r
+}\r
+\r
+void UNL8237A_Init(CartInfo *info)\r
+{\r
+  GenMMC3_Init(info, 256, 256, 0, 0);\r
+  cwrap=UNL8237ACW;\r
+  pwrap=UNL8237APW;\r
+  info->Power=UNL8237Power;\r
+  AddExState(EXPREGS, 3, 0, "EXPR");\r
+  AddExState(&cmdin, 1, 0, "CMDIN");\r
+}\r
diff --git a/boards/830118C.c b/boards/830118C.c
new file mode 100644 (file)
index 0000000..8b6ce60
--- /dev/null
@@ -0,0 +1,82 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2008 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+// M-022 MMC3 based 830118C T-106 4M + 4M\r
+\r
+#include "mapinc.h"\r
+#include "mmc3.h"\r
+\r
+static uint8 reset_flag = 0;\r
+\r
+static void BMC830118CCW(uint32 A, uint8 V)\r
+{\r
+    setchr1(A,(V&0x7F)|((EXPREGS[0]&0x0c)<<5));\r
+}\r
+\r
+static void BMC830118CPW(uint32 A, uint8 V)\r
+{\r
+      if((EXPREGS[0]&0x0C)==0x0C) \r
+      {  \r
+         if(A==0x8000)\r
+         {\r
+           setprg8(A,(V&0x0F)|((EXPREGS[0]&0x0c)<<2));\r
+           setprg8(0xC000,(V&0x0F)|0x32);\r
+         }\r
+         else if(A==0xA000)\r
+         {\r
+           setprg8(A,(V&0x0F)|((EXPREGS[0]&0x0c)<<2));\r
+           setprg8(0xE000,(V&0x0F)|0x32);\r
+         }\r
+      }\r
+      else\r
+      {\r
+         setprg8(A,(V&0x0F)|((EXPREGS[0]&0x0c)<<2));\r
+      }\r
+}\r
+\r
+static DECLFW(BMC830118CLoWrite)\r
+{\r
+  EXPREGS[0] = V;\r
+  FixMMC3PRG(MMC3_cmd);\r
+  FixMMC3CHR(MMC3_cmd);\r
+}\r
+\r
+static void BMC830118CReset(void)\r
+{\r
+  EXPREGS[0]=0;\r
+  MMC3RegReset();\r
+}\r
+\r
+static void BMC830118CPower(void)\r
+{\r
+  EXPREGS[0] = 0;\r
+  GenMMC3Power();\r
+  SetWriteHandler(0x6800,0x68FF,BMC830118CLoWrite);\r
+}\r
+\r
+void BMC830118C_Init(CartInfo *info)\r
+{\r
+  GenMMC3_Init(info, 128, 128, 8, 0);\r
+  pwrap=BMC830118CPW;\r
+  cwrap=BMC830118CCW;\r
+  info->Power=BMC830118CPower;\r
+  info->Reset=BMC830118CReset;\r
+  AddExState(EXPREGS, 1, 0, "EXPR");\r
+}\r
index 03fbf5b..88d45ce 100644 (file)
@@ -15,7 +15,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 #include "mapinc.h"
index 994910d..caccc09 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 #include "mapinc.h"
 //#define DEBUG90
 
-static int is209;
+// Mapper 090 is simpliest mapper hardware and have not extended nametable control and latched chr banks in 4k mode
+// Mapper 209 much compicated hardware with decribed above features disabled by default and switchable by command
+// Mapper 211 the same mapper 209 but with forced nametable control
+
+static int is209; 
 static int is211;
 
 static uint8 IRQMode;        // from $c001
@@ -40,20 +44,23 @@ static uint8 prgb[4];
 static uint8 chrlow[8];
 static uint8 chrhigh[8];
 
+static uint8 chr[2];
+
 static uint16 names[4];
 static uint8 tekker;
 
 static SFORMAT Tek_StateRegs[]={
-  {&IRQMode, 1, "IRQMODE"},
-  {&IRQPre, 1, "IRQPRE"},
-  {&IRQPreSize, 1, "IRQPRESIZE"},
+  {&IRQMode, 1, "IRQM"},
+  {&IRQPre, 1, "IRQP"},
+  {&IRQPreSize, 1, "IRQS"},
   {&IRQCount, 1, "IRQC"},
-  {&IRQXOR, 1, "IRQXOR"},
+  {&IRQXOR, 1, "IRQX"},
   {&IRQa, 1, "IRQa"},
   {mul, 2, "MUL"},
   {&regie, 1, "REGI"},
   {tkcom, 4, "TKCO"},
   {prgb, 4, "PRGB"},
+  {chr, 2, "CHRA"},
   {chrlow, 4, "CHRL"},
   {chrhigh, 8, "CHRH"},
   {&names[0], 2|FCEUSTATE_RLSB, "NMS0"},
@@ -159,8 +166,10 @@ static void tekvrom(void)
          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);
+//         for(x=0;x<8;x+=4)
+//            setchr4(x<<10,((chrlow[x]|(chrhigh[x]<<8))&mask)|bank);
+         setchr4(0x0000,((chrlow[chr[0]]|(chrhigh[chr[0]]<<8))&mask)|bank);
+         setchr4(0x1000,((chrlow[chr[1]]|(chrhigh[chr[1]]<<8))&mask)|bank);
          break;
     case 0x10:      // 2KB
          for(x=0;x<8;x+=2)
@@ -175,7 +184,7 @@ static void tekvrom(void)
 
 static DECLFW(M90TekWrite)
 {
-  switch(A)
+  switch(A&0x5C03)
   {
     case 0x5800: mul[0]=V; break;
     case 0x5801: mul[1]=V; break;
@@ -185,35 +194,40 @@ static DECLFW(M90TekWrite)
 
 static DECLFR(M90TekRead)
 {
-  switch(A)
+  switch(A&0x5C03)
   {
     case 0x5800: return (mul[0]*mul[1]);
     case 0x5801: return((mul[0]*mul[1])>>8);
     case 0x5803: return (regie);
+    default: return tekker;
   }
-  return(tekker);
+  return(0xff);
 }
 
 static DECLFW(M90PRGWrite)
 {
+//  FCEU_printf("bs %04x %02x\n",A,V);
   prgb[A&3]=V;
   tekprom();
 }
 
 static DECLFW(M90CHRlowWrite)
 {
+//  FCEU_printf("bs %04x %02x\n",A,V);
   chrlow[A&7]=V;
   tekvrom();
 }
 
 static DECLFW(M90CHRhiWrite)
 {
+//  FCEU_printf("bs %04x %02x\n",A,V);
   chrhigh[A&7]=V;
   tekvrom();
 }
 
 static DECLFW(M90NTWrite)
 {
+//  FCEU_printf("bs %04x %02x\n",A,V);
   if(A&4)
   {
     names[A&3]&=0x00FF;
@@ -229,6 +243,7 @@ static DECLFW(M90NTWrite)
 
 static DECLFW(M90IRQWrite)
 {
+//  FCEU_printf("bs %04x %02x\n",A,V);
   switch(A&7)
   {
     case 00: //FCEU_printf("%s IRQ (C000)\n",V&1?"Enable":"Disable");
@@ -238,20 +253,20 @@ static DECLFW(M90IRQWrite)
     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;
+             //  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);
@@ -259,14 +274,15 @@ static DECLFW(M90IRQWrite)
     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");
+             //     else if(V==0xFF) FCEU_printf("Prescaler is changed for 12bits\n");
+             //     else FCEU_printf("Counter Stopped\n");
              IRQPreSize=V;break;
   }
 }
 
 static DECLFW(M90ModeWrite)
 {
+//    FCEU_printf("bs %04x %02x\n",A,V);
     tkcom[A&3]=V;
     tekprom();
     tekvrom();
@@ -305,6 +321,11 @@ static DECLFW(M90ModeWrite)
 #endif
 }
 
+static DECLFW(M90DummyWrite)
+{
+//    FCEU_printf("bs %04x %02x\n",A,V);
+}
+
 static void CCL(void)
 {
   if((IRQMode>>6) == 1) // Count Up
@@ -345,7 +366,7 @@ static void ClockCounter(void)
   }
 }
 
-void FP_FASTAPASS(1) CPUWrap(int a)
+void CPUWrap(int a)
 {
   int x;
   if((IRQMode&3)==0) for(x=0;x<a;x++) ClockCounter();
@@ -358,7 +379,7 @@ static void SLWrap(void)
 }
 
 static uint32 lastread;
-static void FP_FASTAPASS(1) M90PPU(uint32 A)
+static void M90PPU(uint32 A)
 {
   if((IRQMode&3)==2)
   {
@@ -369,24 +390,38 @@ static void FP_FASTAPASS(1) M90PPU(uint32 A)
     }
     lastread=A;
   }
-//  else
-//  {
-//    if((!lastread)&&(A&0x1000))
-//      ClockCounter();
-//    lastread=A&0x1000;
-//  }
-
+  
+  if(is209)
+  {
+    uint8 l,h;
+    h=A>>8;
+    if(h<0x20&&((h&0x0F)==0xF))
+    {
+      l=A&0xF0;
+      if(l==0xD0)
+      {
+        chr[(h&0x10)>>4]=((h&0x10)>>2);
+        tekvrom();
+      }
+      else if(l==0xE0)
+      {
+        chr[(h&0x10)>>4]=((h&0x10)>>2)|2;
+        tekvrom();
+      }
+    }
+  }
+  else
+  {
+    chr[0]=0;
+    chr[1]=4;
+  }
 }
 
 static void togglie()
 {
-  tekker>>=6;
-  if(tekker>3)
-    tekker=0;
-  else
-    tekker++;
-  tekker<<=6;
-  FCEU_printf("tekker=%04x\n",tekker);
+  tekker+=0x40;
+  tekker&=0xC0;
+  FCEU_printf("tekker=%02x\n",tekker);
   memset(tkcom,0x00,sizeof(tkcom));
   memset(prgb,0xff,sizeof(prgb));
   tekprom();
@@ -403,12 +438,14 @@ static void M90Restore(int version)
 static void M90Power(void)
 {
   SetWriteHandler(0x5000,0x5fff,M90TekWrite);
-  SetWriteHandler(0x8000,0x8fff,M90PRGWrite);
+  SetWriteHandler(0x8000,0x8ff0,M90PRGWrite);
   SetWriteHandler(0x9000,0x9fff,M90CHRlowWrite);
   SetWriteHandler(0xA000,0xAfff,M90CHRhiWrite);
   SetWriteHandler(0xB000,0xBfff,M90NTWrite);
   SetWriteHandler(0xC000,0xCfff,M90IRQWrite);
-  SetWriteHandler(0xD000,0xDfff,M90ModeWrite);
+  SetWriteHandler(0xD000,0xD5ff,M90ModeWrite);
+  SetWriteHandler(0xE000,0xFfff,M90DummyWrite);
+
 
   SetReadHandler(0x5000,0x5fff,M90TekRead);
   SetReadHandler(0x6000,0xffff,CartBR);
@@ -438,8 +475,8 @@ void Mapper90_Init(CartInfo *info)
   info->Reset=togglie;
   info->Power=M90Power;
   PPU_hook=M90PPU;
-  GameHBIRQHook2=SLWrap;
   MapIRQHook=CPUWrap;
+  GameHBIRQHook2=SLWrap;
   GameStateRestore=M90Restore;
   AddExState(Tek_StateRegs, ~0, 0, 0);
 }
@@ -450,6 +487,8 @@ void Mapper209_Init(CartInfo *info)
   is209=1;
   info->Reset=togglie;
   info->Power=M90Power;
+  PPU_hook=M90PPU;
+  MapIRQHook=CPUWrap;
   GameHBIRQHook2=SLWrap;
   GameStateRestore=M90Restore;
   AddExState(Tek_StateRegs, ~0, 0, 0);
@@ -460,6 +499,8 @@ void Mapper211_Init(CartInfo *info)
   is211=1;
   info->Reset=togglie;
   info->Power=M90Power;
+  PPU_hook=M90PPU;
+  MapIRQHook=CPUWrap;
   GameHBIRQHook2=SLWrap;
   GameStateRestore=M90Restore;
   AddExState(Tek_StateRegs, ~0, 0, 0);
index 7b69435..0a5d9dd 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 #include "mapinc.h"
+#include "../ines.h"
 
 static uint8 lastA;
 static uint8 DRegs[8];
@@ -78,7 +79,7 @@ static DECLFW(Mapper95_write)
   }
 }
 
-static void FP_FASTAPASS(1) dragonbust_ppu(uint32 A)
+static void dragonbust_ppu(uint32 A)
 {
   static int last=-1;
   static uint8 z;
index 7af1889..b14ee56 100644 (file)
@@ -1,51 +1,88 @@
+B_C += boards/01-222.c
+B_C += boards/103.c
+B_C += boards/106.c
+B_C += boards/108.c
 B_C += boards/112.c
+B_C += boards/116.c
 B_C += boards/117.c
+B_C += boards/120.c
+B_C += boards/121.c
+B_C += boards/15.c
 B_C += boards/164.c
+B_C += boards/175.c
+B_C += boards/176.c
+B_C += boards/177.c
+B_C += boards/178.c
+B_C += boards/179.c
 B_C += boards/183.c
 B_C += boards/185.c
 B_C += boards/186.c
 B_C += boards/187.c
 B_C += boards/189.c
+B_C += boards/199.c
 B_C += boards/208.c
 B_C += boards/222.c
+B_C += boards/23.c
 B_C += boards/235.c
+B_C += boards/253.c
+B_C += boards/3d-block.c
+B_C += boards/411120-c.c
+B_C += boards/43.c
 B_C += boards/57.c
+B_C += boards/603-5052.c
+B_C += boards/68.c
 B_C += boards/8157.c
 B_C += boards/8237.c
+B_C += boards/830118C.c
 B_C += boards/88.c
 B_C += boards/90.c
 B_C += boards/95.c
+B_C += boards/a9711.c
+B_C += boards/a9746.c
+B_C += boards/addrlatch.c
+B_C += boards/ax5705.c
+B_C += boards/bandai.c
 B_C += boards/bmc13in1jy110.c
 B_C += boards/bmc42in1r.c
 B_C += boards/bmc64in1nr.c
 B_C += boards/bmc70in1.c
-B_C += boards/bmcgk192.c
 B_C += boards/bonza.c
-B_C += boards/cc21.c
+B_C += boards/bs-5.c
 B_C += boards/datalatch.c
 B_C += boards/deirom.c
 B_C += boards/dream.c
+B_C += boards/__dummy_mapper.c
+B_C += boards/edu2000.c
 B_C += boards/fk23c.c
+B_C += boards/ghostbusters63in1.c
+B_C += boards/gs-2004.c
+B_C += boards/gs-2013.c
 B_C += boards/h2288.c
 B_C += boards/karaoke.c
 B_C += boards/kof97.c
 B_C += boards/konami-qtai.c
+B_C += boards/ks7032.c
 B_C += boards/malee.c
 B_C += boards/mmc1.c
 B_C += boards/mmc3.c
 B_C += boards/mmc5.c
+B_C += boards/n-c22m.c
 B_C += boards/n106.c
+B_C += boards/n625092.c
 B_C += boards/novel.c
+B_C += boards/onebus.c
 B_C += boards/sachen.c
+B_C += boards/sc-127.c
 B_C += boards/sheroes.c
 B_C += boards/sl1632.c
-B_C += boards/sonic5.c
+B_C += boards/smb2j.c
 B_C += boards/subor.c
 B_C += boards/super24.c
 B_C += boards/supervision.c
+B_C += boards/t-227-1.c
 B_C += boards/t-262.c
 B_C += boards/tengen.c
-B_C += boards/__dummy_mapper.c
+B_C += boards/tf-1201.c
 
 MUOBJS += $(patsubst %.c,%.o,$(B_C))
 
index 6bb703c..f56736d 100644 (file)
-/* 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);
-}
-
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2009 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg[8];\r
+/*\r
+static uint8 *WRAM=NULL;\r
+static uint32 WRAMSIZE;\r
+static uint8 *CHRRAM=NULL;\r
+static uint32 CHRRAMSIZE;\r
+*/\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {reg, 8, "REGS"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+}\r
+\r
+static DECLFW(MNNNWrite)\r
+{\r
+}\r
+\r
+static void MNNNPower(void)\r
+{\r
+//  SetReadHandler(0x6000,0x7fff,CartBR);\r
+// SetWriteHandler(0x6000,0x7fff,CartBW);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0xFFFF,MNNNWrite);\r
+}\r
+\r
+static void MNNNReset(void)\r
+{\r
+}\r
+\r
+/*\r
+static void MNNNClose(void)\r
+{\r
+  if(WRAM)\r
+    FCEU_gfree(WRAM);\r
+  if(CHRRAM)\r
+    FCEU_gfree(CHRRAM);\r
+  WRAM=CHRRAM=NULL;\r
+}\r
+*/\r
+\r
+static void MNNNIRQHook(void)\r
+{\r
+  X6502_IRQBegin(FCEU_IQEXT);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void MapperNNN_Init(CartInfo *info)\r
+{\r
+  info->Reset=MNNNReset;\r
+  info->Power=MNNNPower;\r
+//  info->Close=MNNNClose;\r
+  GameHBIRQHook=MNNNIRQHook;\r
+  GameStateRestore=StateRestore;\r
+/*\r
+  CHRRAMSIZE=8192;\r
+  CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSIZE);\r
+  SetupCartCHRMapping(0x10,CHRRAM,CHRRAMSIZE,1);\r
+  AddExState(CHRRAM, CHRRAMSIZE, 0, "CRAM");\r
+*/\r
+/*\r
+  WRAMSIZE=8192;\r
+  WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);\r
+  SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);\r
+  AddExState(WRAM, WRAMSIZE, 0, "WRAM");\r
+  if(info->battery)\r
+  {\r
+    info->SaveGame[0]=WRAM;\r
+    info->SaveGameLen[0]=WRAMSIZE;\r
+  }\r
+*/\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
similarity index 51%
rename from boards/sonic5.c
rename to boards/a9711.c
index 4a55d0d..3fb5460 100644 (file)
@@ -1,73 +1,78 @@
-/* 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");
-}
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2005 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+#include "mmc3.h"\r
+\r
+//static uint8 m_perm[8] = {0, 1, 0, 3, 0, 5, 6, 7};\r
+\r
+static void UNLA9711PW(uint32 A, uint8 V)\r
+{\r
+  if((EXPREGS[0]&0xFF) == 0x37)\r
+  {\r
+    setprg8(0x8000, 0x13);\r
+    setprg8(0xA000, 0x13);\r
+    setprg8(0xC000, 0x13);\r
+    setprg8(0xE000, 0x0);\r
+//    uint8 bank=EXPREGS[0]&0x1F;\r
+//   if(EXPREGS[0]&0x20)\r
+//      setprg32(0x8000,bank>>2);\r
+//    else\r
+//    {\r
+//      setprg16(0x8000,bank);\r
+//      setprg16(0xC000,bank);\r
+//    }\r
+  }\r
+  else\r
+    setprg8(A,V&0x3F);\r
+}\r
+\r
+//static DECLFW(UNLA9711Write8000)\r
+//{\r
+//  FCEU_printf("bs %04x %02x\n",A,V);\r
+//  if(V&0x80)\r
+//    MMC3_CMDWrite(A,V);\r
+//  else\r
+//    MMC3_CMDWrite(A,m_perm[V&7]);\r
+//  if(V!=0x86) MMC3_CMDWrite(A,V);\r
+//}\r
+\r
+static DECLFW(UNLA9711WriteLo)\r
+{\r
+  FCEU_printf("bs %04x %02x\n",A,V);\r
+  EXPREGS[0]=V;\r
+  FixMMC3PRG(MMC3_cmd);\r
+}\r
+\r
+static void UNLA9711Power(void)\r
+{\r
+  EXPREGS[0]=EXPREGS[1]=EXPREGS[2]=0;\r
+  GenMMC3Power();\r
+  SetWriteHandler(0x5000,0x5FFF,UNLA9711WriteLo);\r
+//  SetWriteHandler(0x8000,0xbfff,UNLA9711Write8000);\r
+}\r
+\r
+void UNLA9711_Init(CartInfo *info)\r
+{\r
+  GenMMC3_Init(info, 256, 256, 0, 0);\r
+  pwrap=UNLA9711PW;\r
+  info->Power=UNLA9711Power;\r
+  AddExState(EXPREGS, 3, 0, "EXPR");\r
+}\r
diff --git a/boards/a9746.c b/boards/a9746.c
new file mode 100644 (file)
index 0000000..3522336
--- /dev/null
@@ -0,0 +1,186 @@
+\r
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2007 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+/*\r
+#include "mapinc.h"\r
+\r
+static uint8 chr_cmd, prg_cmd, mirror;\r
+static uint8 chr_reg[6], prg_reg[4];\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&chr_cmd, 1, "CHRCMD"},\r
+  {&prg_cmd, 1, "PRGCMD"},\r
+  {&mirror, 1, "MIRR"},\r
+  {chr_reg, 6, "CREGS"},\r
+  {prg_reg, 4, "PREGS"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setprg8(0x8000, prg_reg[0]);\r
+  setprg8(0xA000, prg_reg[1]); \r
+  setprg8(0xC000, prg_reg[2]); \r
+  setprg8(0xE000, prg_reg[3]);\r
+    \r
+  setchr2(0x0000, chr_reg[0]);\r
+  setchr2(0x0800, chr_reg[1]); \r
+  setchr1(0x1000, chr_reg[2]); \r
+  setchr1(0x1400, chr_reg[3]);\r
+  setchr1(0x1800, chr_reg[4]);\r
+  setchr1(0x1c00, chr_reg[5]); \r
+  \r
+  setmirror(mirror);\r
+}\r
+\r
+static DECLFW(UNLA9746Write)\r
+{\r
+   uint8 bits_rev;    \r
+//   FCEU_printf("write raw %04x:%02x\n",A,V);\r
+   switch (A&0xE003)\r
+   {\r
+//     case 0xA000: mirror = V; break;\r
+     case 0x8000: chr_cmd = V; prg_cmd = 0; break;\r
+     case 0x8002: prg_cmd = V; chr_cmd = 0; break;\r
+     case 0x8001: bits_rev = ((V&0x20)>>5)|((V&0x10)>>3)|((V&0x08)>>1)|((V&0x04)<<1);\r
+//                  if(prg_cmd>0x23)\r
+//                     prg_reg[(0x26-prg_cmd)&3] = bits_rev;\r
+                  switch(chr_cmd)\r
+                  {\r
+                    case 0x08: chr_reg[0] = (V << 3); break;\r
+                    case 0x09: chr_reg[0] = chr_reg[0]|(V >> 2); break;\r
+                    case 0x0e: chr_reg[1] = (V << 3); break;\r
+                    case 0x0d: chr_reg[1] = chr_reg[1]|(V >> 2); break;\r
+                    case 0x12: chr_reg[2] = (V << 4); break;\r
+                    case 0x11: chr_reg[2] = chr_reg[2]|(V >> 1); FCEU_printf("Sync CHR 0x1000:%02x\n",chr_reg[2]); break;\r
+                    case 0x16: chr_reg[3] = (V << 4); break;\r
+                    case 0x15: chr_reg[3] = chr_reg[3]|(V >> 1); break;\r
+                    case 0x1a: chr_reg[4] = (V << 4); break;\r
+                    case 0x19: chr_reg[4] = chr_reg[4]|(V >> 1); break;\r
+                    case 0x1e: chr_reg[5] = (V << 4); break;\r
+                    case 0x1d: chr_reg[5] = chr_reg[5]|(V >> 1); break;\r
+                  }\r
+                  Sync();\r
+                  break;\r
+   }\r
+}\r
+\r
+static void UNLA9746Power(void)\r
+{\r
+  prg_reg[2]=~1;\r
+  prg_reg[3]=~0;\r
+  Sync();\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0xbfff,UNLA9746Write);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void UNLA9746_Init(CartInfo *info)\r
+{\r
+  info->Power=UNLA9746Power;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
+/**/\r
+\r
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2007 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+#include "mmc3.h"\r
+\r
+static DECLFW(UNLA9746Write)\r
+{\r
+//   FCEU_printf("write raw %04x:%02x\n",A,V);\r
+   switch (A&0xE003)\r
+   {\r
+     case 0x8000: EXPREGS[1]=V; EXPREGS[0]=0; break;\r
+     case 0x8002: EXPREGS[0]=V; EXPREGS[1]=0; break;\r
+     case 0x8001: {\r
+                    uint8 bits_rev = ((V&0x20)>>5)|((V&0x10)>>3)|((V&0x08)>>1)|((V&0x04)<<1);\r
+                    switch(EXPREGS[0])\r
+                    {\r
+                      case 0x26: setprg8(0x8000, bits_rev); break;\r
+                      case 0x25: setprg8(0xA000, bits_rev); break; \r
+                      case 0x24: setprg8(0xC000, bits_rev); break; \r
+                      case 0x23: setprg8(0xE000, bits_rev); break;\r
+                    }\r
+                    switch(EXPREGS[1])\r
+                    {\r
+                      case 0x0a:\r
+                      case 0x08: EXPREGS[2] = (V << 4); break;\r
+                      case 0x09: setchr1(0x0000, EXPREGS[2]|(V >> 1)); break;\r
+                      case 0x0b: setchr1(0x0400, EXPREGS[2]|(V >> 1)|1);  break;\r
+                      case 0x0c:\r
+                      case 0x0e: EXPREGS[2] = (V << 4);  break;\r
+                      case 0x0d: setchr1(0x0800, EXPREGS[2]|(V >> 1));  break;\r
+                      case 0x0f: setchr1(0x0c00, EXPREGS[2]|(V >> 1)|1);  break;\r
+                      case 0x10:\r
+                      case 0x12: EXPREGS[2] = (V << 4);  break;\r
+                      case 0x11: setchr1(0x1000, EXPREGS[2]|(V >> 1)); break;\r
+                      case 0x14:\r
+                      case 0x16: EXPREGS[2] = (V << 4);  break;\r
+                      case 0x15: setchr1(0x1400, EXPREGS[2]|(V >> 1));  break;\r
+                      case 0x18:\r
+                      case 0x1a: EXPREGS[2] = (V << 4);  break;\r
+                      case 0x19: setchr1(0x1800, EXPREGS[2]|(V >> 1));  break;\r
+                      case 0x1c:\r
+                      case 0x1e: EXPREGS[2] = (V << 4);  break;\r
+                      case 0x1d: setchr1(0x1c00, EXPREGS[2]|(V >> 1));  break;\r
+                    }\r
+                  }\r
+                  break;\r
+   }\r
+}\r
+\r
+static void UNLA9746Power(void)\r
+{\r
+  GenMMC3Power();\r
+  SetWriteHandler(0x8000,0xbfff,UNLA9746Write);\r
+}\r
+\r
+void UNLA9746_Init(CartInfo *info)\r
+{\r
+  GenMMC3_Init(info, 128, 256, 0, 0);\r
+  info->Power=UNLA9746Power;\r
+  AddExState(EXPREGS, 6, 0, "EXPR");\r
+}\r
+/**/\r
diff --git a/boards/addrlatch.c b/boards/addrlatch.c
new file mode 100644 (file)
index 0000000..4b70d6e
--- /dev/null
@@ -0,0 +1,172 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2006 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint16 latche, latcheinit;\r
+static uint16 addrreg0, addrreg1;\r
+static void(*WSync)(void);\r
+static readfunc defread;\r
+\r
+static DECLFW(LatchWrite)\r
+{\r
+  FCEU_printf("%04x:%02x\n",A,V);\r
+  latche=A;\r
+  WSync();\r
+}\r
+\r
+static void LatchReset(void)\r
+{\r
+  latche=latcheinit;\r
+  WSync();\r
+}\r
+\r
+static void LatchPower(void)\r
+{\r
+  latche=latcheinit;\r
+  WSync();\r
+  SetReadHandler(0x8000,0xFFFF,defread);\r
+  SetWriteHandler(addrreg0,addrreg1,LatchWrite);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  WSync();\r
+}\r
+\r
+static void Latch_Init(CartInfo *info, void (*proc)(void), readfunc func, uint16 init, uint16 adr0, uint16 adr1)\r
+{\r
+  latcheinit=init;\r
+  addrreg0=adr0;\r
+  addrreg1=adr1;\r
+  WSync=proc;\r
+  if(func)\r
+    defread=func;\r
+  else\r
+    defread=CartBR;\r
+  info->Power=LatchPower;\r
+  info->Reset=LatchReset;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&latche, 2, 0, "LATC");\r
+}\r
+\r
+//------------------ UNLCC21 ---------------------------\r
+\r
+static void UNLCC21Sync(void)\r
+{\r
+  setprg32(0x8000,0);\r
+  setchr8(latche&1);\r
+  setmirror(MI_0+((latche&2)>>1));\r
+}\r
+\r
+void UNLCC21_Init(CartInfo *info)\r
+{ \r
+  Latch_Init(info, UNLCC21Sync, 0, 0, 0x8000, 0xFFFF);\r
+}\r
+\r
+//------------------ BMCD1038 ---------------------------\r
+\r
+static uint8 dipswitch;\r
+static void BMCD1038Sync(void)\r
+{\r
+  if(latche&0x80)\r
+  {\r
+    setprg16(0x8000,(latche&0x70)>>4);\r
+    setprg16(0xC000,(latche&0x70)>>4);\r
+  }\r
+  else\r
+    setprg32(0x8000,(latche&0x60)>>5);\r
+  setchr8(latche&7);\r
+  setmirror(((latche&8)>>3)^1);\r
+}\r
+\r
+static DECLFR(BMCD1038Read)\r
+{\r
+  if(latche&0x100)\r
+    return dipswitch;\r
+  else\r
+    return CartBR(A);\r
+}\r
+\r
+static void BMCD1038Reset(void)\r
+{\r
+  dipswitch++;\r
+  dipswitch&=3; \r
+}\r
+\r
+void BMCD1038_Init(CartInfo *info)\r
+{ \r
+  Latch_Init(info, BMCD1038Sync, BMCD1038Read, 0, 0x8000, 0xFFFF);\r
+  info->Reset=BMCD1038Reset;\r
+  AddExState(&dipswitch, 1, 0, "DIPSW");\r
+}\r
+\r
+\r
+//------------------ Map 058 ---------------------------\r
+\r
+static void BMCGK192Sync(void)\r
+{\r
+  if(latche&0x40)\r
+  {\r
+    setprg16(0x8000,latche&7);\r
+    setprg16(0xC000,latche&7);\r
+  }\r
+  else\r
+    setprg32(0x8000,(latche>>1)&3);\r
+  setchr8((latche>>3)&7);\r
+  setmirror(((latche&0x80)>>7)^1);\r
+}\r
+\r
+void BMCGK192_Init(CartInfo *info)\r
+{\r
+  Latch_Init(info, BMCGK192Sync, 0, 0, 0x8000, 0xFFFF);\r
+}\r
+\r
+//------------------ Map 200 ---------------------------\r
+\r
+static void M200Sync(void)\r
+{\r
+//  FCEU_printf("A\n");\r
+  setprg16(0x8000,latche&7);\r
+  setprg16(0xC000,latche&7);\r
+  setchr8(latche&7);\r
+  setmirror((latche&8)>>3);\r
+}\r
+\r
+void Mapper200_Init(CartInfo *info)\r
+{ \r
+  Latch_Init(info, M200Sync, 0, 0xff, 0x8000, 0xFFFF);\r
+}\r
+\r
+//------------------ 190in1 ---------------------------\r
+\r
+static void BMC190in1Sync(void)\r
+{\r
+  setprg16(0x8000,(latche>>2)&0x07);\r
+  setprg16(0xC000,(latche>>2)&0x07);\r
+  setchr8((latche>>2)&0x07);\r
+  setmirror((latche&1)^1);\r
+}\r
+\r
+void BMC190in1_Init(CartInfo *info)\r
+{ \r
+  Latch_Init(info, BMC190in1Sync, 0, 0, 0x8000, 0xFFFF);\r
+}\r
+\r
diff --git a/boards/ax5705.c b/boards/ax5705.c
new file mode 100644 (file)
index 0000000..66f1498
--- /dev/null
@@ -0,0 +1,122 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2007 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ *\r
+ * Super Bros. Pocker Mali (VRC4 mapper)\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 IRQCount;//, IRQPre;\r
+static uint8 IRQa;\r
+static uint8 prg_reg[2];\r
+static uint8 chr_reg[8];\r
+static uint8 mirr;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&IRQCount, 1, "IRQC"},\r
+  {&IRQa, 1, "IRQA"},\r
+  {prg_reg, 2, "PRG"},\r
+  {chr_reg, 8, "CHR"},\r
+  {&mirr, 1, "MIRR"},\r
+  {0}\r
+};\r
+\r
+/*\r
+static void UNLAX5705IRQ(void)\r
+{\r
+  if(IRQa)\r
+  {\r
+    IRQCount++;\r
+    if(IRQCount>=238)\r
+    {\r
+      X6502_IRQBegin(FCEU_IQEXT);\r
+//      IRQa=0;\r
+    }\r
+  }\r
+}*/\r
+\r
+static void Sync(void)\r
+{\r
+  int i;\r
+  setprg8(0x8000,prg_reg[0]);\r
+  setprg8(0xA000,prg_reg[1]);\r
+  setprg8(0xC000,~1);\r
+  setprg8(0xE000,~0);\r
+  for(i=0; i<8; i++)\r
+     setchr1(i<<10,chr_reg[i]);     \r
+  setmirror(mirr^1);   \r
+}\r
+\r
+static DECLFW(UNLAX5705Write)\r
+{\r
+//  if((A>=0xA008)&&(A<=0xE003))\r
+//  {\r
+//    int ind=(((A>>11)-6)|(A&1))&7;\r
+//    int sar=((A&2)<<1);\r
+//    chr_reg[ind]=(chr_reg[ind]&(0xF0>>sar))|((V&0x0F)<<sar);\r
+//    SyncChr();\r
+//  }\r
+//  else \r
+  switch(A&0xF00F)\r
+  {\r
+    case 0x8000: prg_reg[0]=((V&2)<<2)|((V&8)>>2)|(V&5); break; // EPROM dump have mixed PRG and CHR banks, data lines to mapper seems to be mixed\r
+    case 0x8008: mirr=V&1; break;\r
+    case 0xA000: prg_reg[1]=((V&2)<<2)|((V&8)>>2)|(V&5); break;\r
+    case 0xA008: chr_reg[0]=(chr_reg[0]&0xF0)|(V&0x0F); break;\r
+    case 0xA009: chr_reg[0]=(chr_reg[0]&0x0F)|((((V&4)>>1)|((V&2)<<1)|(V&0x09))<<4); break;\r
+    case 0xA00A: chr_reg[1]=(chr_reg[1]&0xF0)|(V&0x0F); break;\r
+    case 0xA00B: chr_reg[1]=(chr_reg[1]&0x0F)|((((V&4)>>1)|((V&2)<<1)|(V&0x09))<<4); break;\r
+    case 0xC000: chr_reg[2]=(chr_reg[2]&0xF0)|(V&0x0F); break;\r
+    case 0xC001: chr_reg[2]=(chr_reg[2]&0x0F)|((((V&4)>>1)|((V&2)<<1)|(V&0x09))<<4); break;\r
+    case 0xC002: chr_reg[3]=(chr_reg[3]&0xF0)|(V&0x0F); break;\r
+    case 0xC003: chr_reg[3]=(chr_reg[3]&0x0F)|((((V&4)>>1)|((V&2)<<1)|(V&0x09))<<4); break;\r
+    case 0xC008: chr_reg[4]=(chr_reg[4]&0xF0)|(V&0x0F); break;\r
+    case 0xC009: chr_reg[4]=(chr_reg[4]&0x0F)|((((V&4)>>1)|((V&2)<<1)|(V&0x09))<<4); break;\r
+    case 0xC00A: chr_reg[5]=(chr_reg[5]&0xF0)|(V&0x0F); break;\r
+    case 0xC00B: chr_reg[5]=(chr_reg[5]&0x0F)|((((V&4)>>1)|((V&2)<<1)|(V&0x09))<<4); break;\r
+    case 0xE000: chr_reg[6]=(chr_reg[6]&0xF0)|(V&0x0F); break;\r
+    case 0xE001: chr_reg[6]=(chr_reg[6]&0x0F)|((((V&4)>>1)|((V&2)<<1)|(V&0x09))<<4); break;\r
+    case 0xE002: chr_reg[7]=(chr_reg[7]&0xF0)|(V&0x0F); break;\r
+    case 0xE003: chr_reg[7]=(chr_reg[7]&0x0F)|((((V&4)>>1)|((V&2)<<1)|(V&0x09))<<4); break;\r
+//    case 0x800A: X6502_IRQEnd(FCEU_IQEXT); IRQa=0; break;\r
+//    case 0xE00B: X6502_IRQEnd(FCEU_IQEXT); IRQa=IRQCount=V; /*if(scanline<240) IRQCount-=8; else IRQCount+=4;*/  break;\r
+  }\r
+  Sync();\r
+}\r
+\r
+static void UNLAX5705Power(void)\r
+{\r
+  Sync();\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0xFFFF,UNLAX5705Write);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void UNLAX5705_Init(CartInfo *info)\r
+{\r
+  info->Power=UNLAX5705Power;\r
+//  GameHBIRQHook=UNLAX5705IRQ;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
diff --git a/boards/bandai.c b/boards/bandai.c
new file mode 100644 (file)
index 0000000..8468aad
--- /dev/null
@@ -0,0 +1,176 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2007 CaH4e3\r
+ *  Copyright (C) 2011 FCEUX team\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ *\r
+ * Bandai mappers\r
+ *\r
+ */\r
+\r
+//Famicom Jump 2 should get transformed to m153\r
+//All other games are not supporting EEPROM saving right now. \r
+//We may need to distinguish between 16 and 159 in order to know the EEPROM configuration.\r
+//Until then, we just return 0x00 from the EEPROM read\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg[16], is153;\r
+static uint8 IRQa;\r
+static int16 IRQCount, IRQLatch;\r
+\r
+static uint8 *WRAM=NULL;\r
+static uint32 WRAMSIZE;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {reg, 16, "REGS"},\r
+  {&IRQa, 1, "IRQA"},\r
+  {&IRQCount, 2, "IRQC"},\r
+  {&IRQLatch, 2, "IRQL"}, // need for Famicom Jump II - Saikyou no 7 Nin (J) [!]\r
+  {0}\r
+};\r
+\r
+static void BandaiIRQHook(int a)\r
+{\r
+  if(IRQa)\r
+  {\r
+    IRQCount -= a;\r
+    if(IRQCount<0)\r
+    {\r
+      X6502_IRQBegin(FCEU_IQEXT);\r
+      IRQa = 0;\r
+      IRQCount = -1;\r
+    }\r
+  }\r
+}\r
+\r
+static void BandaiSync(void)\r
+{\r
+  if(is153)\r
+  {\r
+    int base=(reg[0]&1)<<4;\r
+    setchr8(0);\r
+    setprg16(0x8000,(reg[8]&0x0F)|base);\r
+    setprg16(0xC000,0x0F|base);\r
+  }\r
+  else\r
+  {\r
+    int i;\r
+    for(i=0; i<8; i++) setchr1(i<<10,reg[i]);\r
+    setprg16(0x8000,reg[8]);\r
+    setprg16(0xC000,~0);\r
+  }\r
+  switch(reg[9]&3)\r
+  {\r
+    case 0: setmirror(MI_V); break;\r
+    case 1: setmirror(MI_H); break;\r
+    case 2: setmirror(MI_0); break;\r
+    case 3: setmirror(MI_1); break;\r
+  }\r
+}\r
+\r
+static DECLFW(BandaiWrite)\r
+{\r
+  A&=0x0F;\r
+  if(A<0x0A)\r
+  {\r
+    reg[A&0x0F]=V;\r
+    BandaiSync();\r
+  }\r
+  else\r
+    switch(A)\r
+    {\r
+      case 0x0A: X6502_IRQEnd(FCEU_IQEXT); IRQa=V&1; IRQCount=IRQLatch; break;\r
+      case 0x0B: IRQLatch&=0xFF00; IRQLatch|=V;  break;\r
+      case 0x0C: IRQLatch&=0xFF; IRQLatch|=V<<8; break;\r
+      case 0x0D: break;// Serial EEPROM control port\r
+    }\r
+}\r
+\r
+DECLFR(BandaiRead)
+{
+       return 0;
+}\r
+\r
+static void BandaiPower(void)\r
+{\r
+  BandaiSync();\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x6000,0xFFFF,BandaiWrite);\r
+  SetReadHandler(0x6000,0x7FFF,BandaiRead);\r
+}\r
+\r
+static void M153Power(void)\r
+{\r
+  BandaiSync();\r
+  setprg8r(0x10,0x6000,0);\r
+  SetReadHandler(0x6000,0x7FFF,CartBR);\r
+  SetWriteHandler(0x6000,0x7FFF,CartBW);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0xFFFF,BandaiWrite);\r
+}\r
+\r
+\r
+static void M153Close(void)\r
+{\r
+  if(WRAM)\r
+    FCEU_gfree(WRAM);\r
+  WRAM=NULL;\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  BandaiSync();\r
+}\r
+\r
+void Mapper16_Init(CartInfo *info)\r
+{\r
+  is153=0;\r
+  info->Power=BandaiPower;\r
+  MapIRQHook=BandaiIRQHook;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
+\r
+void Mapper159_Init(CartInfo *info)\r
+{\r
+  Mapper16_Init(info);\r
+}\r
+\r
+\r
+void Mapper153_Init(CartInfo *info)\r
+{\r
+  is153=1;\r
+  info->Power=M153Power;\r
+  info->Close=M153Close;\r
+  MapIRQHook=BandaiIRQHook;\r
+\r
+  WRAMSIZE=8192;\r
+  WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);\r
+  SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);\r
+  AddExState(WRAM, WRAMSIZE, 0, "WRAM");\r
+\r
+  if(info->battery)\r
+  {\r
+    info->SaveGame[0]=WRAM;\r
+    info->SaveGameLen[0]=WRAMSIZE;\r
+  }\r
+\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
index 6f11f8a..89aa4fb 100644 (file)
-/* 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;
-}
-
-
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2005 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ *\r
+ * BMC 42-in-1 reset switch\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 bank_mode;\r
+static uint8 bank_value;\r
+static uint8 prgb[4];\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  FCEU_printf("%02x: %02x %02x\n", bank_mode, bank_value, prgb[0]);  \r
+  switch(bank_mode&7)\r
+  {\r
+    case 0:\r
+         setprg32(0x8000,bank_value&7); break;\r
+    case 1:\r
+         setprg16(0x8000,((8+(bank_value&7))>>1)+prgb[1]);\r
+         setprg16(0xC000,(bank_value&7)>>1);\r
+    case 4:\r
+         setprg32(0x8000,8+(bank_value&7)); break;\r
+    case 5:\r
+         setprg16(0x8000,((8+(bank_value&7))>>1)+prgb[1]);\r
+         setprg16(0xC000,((8+(bank_value&7))>>1)+prgb[3]);\r
+    case 2:\r
+         setprg8(0x8000,prgb[0]>>2);\r
+         setprg8(0xa000,prgb[1]);\r
+         setprg8(0xc000,prgb[2]);\r
+         setprg8(0xe000,~0);\r
+         break;\r
+    case 3:\r
+         setprg8(0x8000,prgb[0]);\r
+         setprg8(0xa000,prgb[1]);\r
+         setprg8(0xc000,prgb[2]);\r
+         setprg8(0xe000,prgb[3]);\r
+         break;\r
+  }\r
+}\r
+\r
+static DECLFW(BMC13in1JY110Write)\r
+{\r
+  FCEU_printf("%04x:%04x\n",A,V);\r
+  switch(A)\r
+  {\r
+    case 0x8000:\r
+    case 0x8001:\r
+    case 0x8002:\r
+    case 0x8003: prgb[A&3]=V; break;\r
+    case 0xD000: bank_mode=V; break;\r
+    case 0xD001: setmirror(V&3);\r
+    case 0xD002: break;\r
+    case 0xD003: bank_value=V; break;\r
+  }\r
+  Sync();\r
+}\r
+\r
+static void BMC13in1JY110Power(void)\r
+{\r
+  prgb[0]=prgb[1]=prgb[2]=prgb[3]=0;\r
+  bank_mode=0;\r
+  bank_value=0;\r
+  setprg32(0x8000,0);\r
+  setchr8(0);\r
+  SetWriteHandler(0x8000,0xFFFF,BMC13in1JY110Write);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void BMC13in1JY110_Init(CartInfo *info)\r
+{\r
+  info->Power=BMC13in1JY110Power;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+  GameStateRestore=StateRestore;\r
+}\r
+\r
+\r
index 8084847..bcbdfc1 100644 (file)
@@ -1,87 +1,76 @@
-/* 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;
-}
-
-
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2005 CaH4e3\r
+ *  Copyright (C) 2009 qeed\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ *\r
+ * BMC 42-in-1\r
+ * it seems now, mapper not reset-based,\r
+ * tested on real hardware and it does menus switch by pressing just Select, not Reset\r
+ * new registers behaviour proven this too\r
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 latche[2];\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&latche, sizeof(latche), "LATCHE"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  uint8 bank = (latche[0]&0x1f)|((latche[0]&0x80)>>2)|((latche[1]&1))<<6;\r
+  if(!(latche[0] & 0x20))\r
+      setprg32(0x8000,bank >> 1);\r
+  else\r
+  {\r
+      setprg16(0x8000,bank);\r
+      setprg16(0xC000,bank);\r
+  }\r
+  setmirror((latche[0]>>6)&1);\r
+  setchr8(0);\r
+}\r
+\r
+static DECLFW(M226Write)\r
+{\r
+    latche[A & 1] = V;\r
+    Sync();\r
+}\r
+\r
+static void M226Power(void)\r
+{\r
+  latche[0] = latche[1] = 0;\r
+  Sync();\r
+  SetWriteHandler(0x8000,0xFFFF,M226Write);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper226_Init(CartInfo *info)\r
+{\r
+  info->Power=M226Power;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+  GameStateRestore=StateRestore;\r
+}\r
+\r
index af663ba..4f90c9f 100644 (file)
@@ -1,93 +1,93 @@
-/* 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;
-}
-
-
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2005 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ *\r
+ * BMC 42-in-1 reset switch\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 regs[4];\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {regs, 4, "REGS"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  if(regs[0]&0x80)\r
+  {\r
+    if(regs[1]&0x80)\r
+      setprg32(0x8000,regs[1]&0x1F);\r
+    else\r
+    {\r
+      int bank=((regs[1]&0x1f)<<1)|((regs[1]>>6)&1);\r
+      setprg16(0x8000,bank);\r
+      setprg16(0xC000,bank);\r
+    }\r
+  }\r
+  else\r
+  {\r
+    int bank=((regs[1]&0x1f)<<1)|((regs[1]>>6)&1);\r
+    setprg16(0xC000,bank);\r
+  }\r
+  if(regs[0]&0x20)\r
+    setmirror(MI_H);\r
+  else\r
+    setmirror(MI_V);\r
+  setchr8((regs[2]<<2)|((regs[0]>>1)&3));\r
+}\r
+\r
+static DECLFW(BMC64in1nrWriteLo)\r
+{\r
+  regs[A&3]=V;\r
+  Sync();\r
+}\r
+\r
+static DECLFW(BMC64in1nrWriteHi)\r
+{\r
+  regs[3]=V;\r
+  Sync();\r
+}\r
+\r
+static void BMC64in1nrPower(void)\r
+{\r
+  regs[0]=0x80;\r
+  regs[1]=0x43;\r
+  regs[2]=regs[3]=0;\r
+  Sync();\r
+  SetWriteHandler(0x5000,0x5003,BMC64in1nrWriteLo);\r
+  SetWriteHandler(0x8000,0xFFFF,BMC64in1nrWriteHi);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void BMC64in1nr_Init(CartInfo *info)\r
+{\r
+  info->Power=BMC64in1nrPower;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+  GameStateRestore=StateRestore;\r
+}\r
+\r
+\r
index 9d4eb28..75baaa5 100644 (file)
-/* 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);
-}
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2005 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 is_large_banks, hw_switch;\r
+static uint8 large_bank;\r
+static uint8 prg_bank;\r
+static uint8 chr_bank;\r
+static uint8 bank_mode;\r
+static uint8 mirroring;\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&large_bank, 1, "LB"},\r
+  {&hw_switch, 1, "DIPSW"},\r
+  {&prg_bank, 1, "PRG"},\r
+  {&chr_bank, 1, "CHR"},\r
+  {&bank_mode, 1, "BM"},\r
+  {&mirroring, 1, "MIRR"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  switch (bank_mode)\r
+  {\r
+    case 0x00:\r
+    case 0x10: setprg16(0x8000,large_bank|prg_bank);\r
+               setprg16(0xC000,large_bank|7);\r
+               break;\r
+    case 0x20: setprg32(0x8000,(large_bank|prg_bank)>>1);\r
+               break;\r
+    case 0x30: setprg16(0x8000,large_bank|prg_bank);\r
+               setprg16(0xC000,large_bank|prg_bank);\r
+               break;\r
+  }\r
+  setmirror(mirroring);\r
+  if(!is_large_banks)\r
+    setchr8(chr_bank);\r
+}\r
+\r
+static DECLFR(BMC70in1Read)\r
+{\r
+  if(bank_mode==0x10)\r
+//    if(is_large_banks)\r
+      return CartBR((A&0xFFF0)|hw_switch);\r
+//    else\r
+//      return CartBR((A&0xFFF0)|hw_switch);\r
+  else\r
+    return CartBR(A);\r
+}\r
+\r
+static DECLFW(BMC70in1Write)\r
+{\r
+  if(A&0x4000)\r
+  {\r
+    bank_mode=A&0x30;\r
+    prg_bank=A&7;\r
+  }\r
+  else\r
+  {\r
+    mirroring=((A&0x20)>>5)^1;\r
+    if(is_large_banks)\r
+      large_bank=(A&3)<<3;\r
+    else\r
+      chr_bank=A&7;\r
+  }\r
+  Sync();\r
+}\r
+\r
+static void BMC70in1Reset(void)\r
+{\r
+  bank_mode=0;\r
+  large_bank=0;\r
+  Sync();\r
+  hw_switch++;\r
+  hw_switch&=0xf;\r
+}\r
+\r
+static void BMC70in1Power(void)\r
+{\r
+  setchr8(0);\r
+  bank_mode=0;\r
+  large_bank=0;\r
+  Sync();\r
+  SetReadHandler(0x8000,0xFFFF,BMC70in1Read);\r
+  SetWriteHandler(0x8000,0xffff,BMC70in1Write);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void BMC70in1_Init(CartInfo *info)\r
+{\r
+  is_large_banks=0;\r
+  hw_switch=0xd;\r
+  info->Power=BMC70in1Power;\r
+  info->Reset=BMC70in1Reset;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
+\r
+void BMC70in1B_Init(CartInfo *info)\r
+{\r
+  is_large_banks=1;\r
+  hw_switch=0x6;\r
+  info->Power=BMC70in1Power;\r
+  info->Reset=BMC70in1Reset;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
index ba390e6..a618f90 100644 (file)
-/* 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);
-}
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2002 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+#define CARD_EXTERNAL_INSERED 0x80\r
+\r
+static uint8 prg_reg;\r
+static uint8 chr_reg;\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&prg_reg, 1, "PREG"},\r
+  {&chr_reg, 1, "CREG"},\r
+  {0}\r
+};\r
+\r
+/*\r
+\r
+_GET_CHALLENGE:      .BYTE   0,$B4,  0,  0,$62\r
+\r
+_SELECT_FILE_1_0200: .BYTE   0,$A4,  1,  0,  2,  2,  0\r
+_SELECT_FILE_2_0201: .BYTE   0,$A4,  2,  0,  2,  2,  1\r
+_SELECT_FILE_2_0203: .BYTE   0,$A4,  2,  0,  2,  2,  3\r
+_SELECT_FILE_2_0204: .BYTE   0,$A4,  2,  0,  2,  2,  4\r
+_SELECT_FILE_2_0205: .BYTE   0,$A4,  2,  0,  2,  2,  5\r
+_SELECT_FILE_2_3F04: .BYTE   0,$A4,  2,  0,  2,$3F,  4\r
+_SELECT_FILE_2_4F00: .BYTE   0,$A4,  2,  0,  2,$4F,  0\r
+\r
+_READ_BINARY_5:      .BYTE   0,$B0,$85,  0,  2\r
+_READ_BINARY_6:      .BYTE   0,$B0,$86,  0,  4\r
+_READ_BINARY_6_0:    .BYTE   0,$B0,$86,  0,$18\r
+_READ_BINARY_0:      .BYTE   0,$B0,  0,  2,  3\r
+_READ_BINARY_0_0:    .BYTE   0,$B0,  0,  0,  4\r
+_READ_BINARY_0_1:    .BYTE   0,$B0,  0,  0, $C\r
+_READ_BINARY_0_2:    .BYTE   0,$B0,  0,  0,$10\r
+\r
+_UPDATE_BINARY:      .BYTE   0,$D6,  0,  0,  4\r
+_UPDATE_BINARY_0:    .BYTE   0,$D6,  0,  0,$10\r
+\r
+_GET_RESPONSE:       .BYTE $80,$C0,  2,$A1,  8\r
+_GET_RESPONSE_0:     .BYTE   0,$C0,  0,  0,  2\r
+_GET_RESPONSE_1:     .BYTE   0,$C0,  0,  0,  6\r
+_GET_RESPONSE_2:     .BYTE   0,$C0,  0,  0,  8\r
+_GET_RESPONSE_3:     .BYTE   0,$C0,  0,  0, $C\r
+_GET_RESPONSE_4:     .BYTE   0,$C0,  0,  0,$10\r
+\r
+byte_8C0B:           .BYTE $80,$30,  0,  2, $A,  0,  1\r
+byte_8C48:           .BYTE $80,$32,  0,  1,  4\r
+byte_8C89:           .BYTE $80,$34,  0,  0,  8,  0,  0\r
+byte_8D01:           .BYTE $80,$36,  0,  0, $C\r
+byte_8CA7:           .BYTE $80,$38,  0,  2,  4\r
+byte_8BEC:           .BYTE $80,$3A,  0,  3,  0\r
+\r
+byte_89A0:           .BYTE   0,$48,  0,  0,  6\r
+byte_8808:           .BYTE   0,$54,  0,  0,$1C\r
+byte_89BF:           .BYTE   0,$58,  0,  0,$1C\r
+\r
+_MANAGE_CHANNEL:     .BYTE   0,$70,  0,  0,  8\r
+byte_8CE5:           .BYTE   0,$74,  0,  0,$12\r
+byte_8C29:           .BYTE   0,$76,  0,  0,  8\r
+byte_8CC6:           .BYTE   0,$78,  0,  0,$12\r
+*/\r
+\r
+static uint8 sim0reset[0x1F] = { 0x3B, 0xE9, 0x00, 0xFF, 0xC1, 0x10, 0x31, 0xFE,\r
+                                 0x55, 0xC8, 0x10, 0x20, 0x55, 0x47, 0x4F, 0x53,\r
+                                 0x56, 0x53, 0x43, 0xAD, 0x10, 0x10, 0x10, 0x10,\r
+                                 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10 }; \r
+\r
+static void Sync(void)\r
+{\r
+  setprg32(0x8000, prg_reg);\r
+  setchr8(chr_reg);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+static DECLFW(M216WriteHi)\r
+{\r
+  prg_reg=A&1;\r
+  chr_reg=(A&0x0E)>>1;\r
+  Sync();\r
+}\r
+\r
+static DECLFW(M216Write5000)\r
+{\r
+//  FCEU_printf("WRITE: %04x:%04x (PC=%02x cnt=%02x)\n",A,V,X.PC,sim0bcnt);\r
+}\r
+\r
+static DECLFR(M216Read5000)\r
+{\r
+//    FCEU_printf("READ: %04x PC=%04x out=%02x byte=%02x cnt=%02x bit=%02x\n",A,X.PC,sim0out,sim0byte,sim0bcnt,sim0bit);\r
+    return 0;\r
+}\r
+\r
+static void Power(void)\r
+{\r
+  prg_reg = 0;\r
+  chr_reg = 0;\r
+  Sync();\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0xFFFF,M216WriteHi);\r
+  SetWriteHandler(0x5000,0x5000,M216Write5000);\r
+  SetReadHandler(0x5000,0x5000,M216Read5000);\r
+}\r
+\r
+\r
+void Mapper216_Init(CartInfo *info)\r
+{\r
+  info->Power=Power;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
diff --git a/boards/bs-5.c b/boards/bs-5.c
new file mode 100644 (file)
index 0000000..ad7a82a
--- /dev/null
@@ -0,0 +1,91 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2007 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg_prg[4];\r
+static uint8 reg_chr[4];\r
+static uint8 dip_switch;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {reg_prg, 4, "PREGS"},\r
+  {reg_chr, 4, "CREGS"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setprg8(0x8000,reg_prg[0]);\r
+  setprg8(0xa000,reg_prg[1]);\r
+  setprg8(0xc000,reg_prg[2]);\r
+  setprg8(0xe000,reg_prg[3]);\r
+  setchr2(0x0000,reg_chr[0]);\r
+  setchr2(0x0800,reg_chr[1]);\r
+  setchr2(0x1000,reg_chr[2]);\r
+  setchr2(0x1800,reg_chr[3]);\r
+  setmirror(MI_V);\r
+}\r
+\r
+static DECLFW(MBS5Write)\r
+{\r
+  int bank_sel = (A&0xC00)>>10;\r
+  switch (A&0xF000)\r
+  {\r
+    case 0x8000:\r
+         reg_chr[bank_sel]=A&0x1F;\r
+         break;\r
+    case 0xA000:\r
+         if(A&(1<<(dip_switch+4)))\r
+          reg_prg[bank_sel]=A&0x0F;\r
+         break;\r
+  }\r
+  Sync();\r
+}\r
+\r
+static void MBS5Reset(void)\r
+{\r
+  dip_switch++;\r
+  dip_switch&=3;\r
+  reg_prg[0]=reg_prg[1]=reg_prg[2]=reg_prg[3]=~0;     \r
+  Sync();\r
+}\r
+\r
+static void MBS5Power(void)\r
+{\r
+  dip_switch=0;\r
+  reg_prg[0]=reg_prg[1]=reg_prg[2]=reg_prg[3]=~0;     \r
+  Sync();\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0xFFFF,MBS5Write);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void BMCBS5_Init(CartInfo *info)\r
+{\r
+  info->Power=MBS5Power;\r
+  info->Reset=MBS5Reset;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
index b3452fe..4a61f04 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 #include "mapinc.h"
+#include "../ines.h"
 
-static uint8 latche, latcheinit;
+static uint8 latche, latcheinit, bus_conflict;
 static uint16 addrreg0, addrreg1;
+static uint8 *WRAM=NULL;
+static uint32 WRAMSIZE;
 static void(*WSync)(void);
 
 static DECLFW(LatchWrite)
 {
+//  FCEU_printf("bs %04x %02x\n",A,V);
+  if(bus_conflict)
+    latche=V&CartBR(A);
+  else
   latche=V;
   WSync();
 }
@@ -34,23 +41,52 @@ static void LatchPower(void)
 {
   latche=latcheinit;
   WSync();
-  SetReadHandler(0x8000,0xFFFF,CartBR);
+       if(WRAM)
+       {
+               SetReadHandler(0x6000,0xFFFF,CartBR);
+               SetWriteHandler(0x6000,0x7FFF,CartBW);
+       }
+       else
+       {
+               SetReadHandler(0x8000,0xFFFF,CartBR);
+       }
   SetWriteHandler(addrreg0,addrreg1,LatchWrite);
 }
 
+static void LatchClose(void)
+{
+  if(WRAM)
+    FCEU_gfree(WRAM);
+  WRAM=NULL;
+}
+
 static void StateRestore(int version)
 {
   WSync();
 }
 
-void Latch_Init(CartInfo *info, void (*proc)(void), uint8 init, uint16 adr0, uint16 adr1)
+static void Latch_Init(CartInfo *info, void (*proc)(void), uint8 init, uint16 adr0, uint16 adr1, uint8 wram, uint8 busc)
 {
+  bus_conflict = busc;
   latcheinit=init;
   addrreg0=adr0;
   addrreg1=adr1;
   WSync=proc;
   info->Power=LatchPower;
+  info->Close=LatchClose;
   GameStateRestore=StateRestore;
+  if(wram)
+  {
+    WRAMSIZE=8192;
+    WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);
+    SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);
+    if(info->battery)
+    {
+      info->SaveGame[0]=WRAM;
+      info->SaveGameLen[0]=WRAMSIZE;
+    }
+    AddExState(WRAM, WRAMSIZE, 0, "WRAM");
+  }
   AddExState(&latche, 1, 0, "LATC");
 }
 
@@ -66,21 +102,40 @@ static void CPROMSync(void)
 
 void CPROM_Init(CartInfo *info)
 {
-  Latch_Init(info, CPROMSync, 0, 0x8000, 0xFFFF);
+  Latch_Init(info, CPROMSync, 0, 0x8000, 0xFFFF, 0, 0);
 }
 
-//------------------ CNROM ---------------------------
+//------------------ Map 184 ---------------------------
 
-static void CNROMSync(void)
+static void M184Sync(void)
 {
-  setchr8(latche&3);
+  setchr4(0x0000,latche);
+  setchr4(0x1000,latche>>4);
   setprg16(0x8000,0);
   setprg16(0xC000,1);
 }
 
+void Mapper184_Init(CartInfo *info)
+{
+  Latch_Init(info, M184Sync, 0, 0x6000, 0x7FFF, 0, 0);
+}
+
+//------------------ CNROM ---------------------------
+
+static void CNROMSync(void)
+{
+       //mbg 8/10/08 - fixed this so that large homebrew roms would work.
+       //setchr8(latche&3);
+       setchr8(latche);
+       setprg16(0x8000,0);
+       setprg16(0xC000,1);
+  setprg8r(0x10,0x6000,0); // Hayauchy IGO uses 2Kb or RAM
+}
+
 void CNROM_Init(CartInfo *info)
 {
-  Latch_Init(info, CNROMSync, 0, 0x8000, 0xFFFF);
+       bool busc = MasterRomInfoParams.ContainsKey("busc");
+       Latch_Init(info, CNROMSync, 0, 0x8000, 0xFFFF, 1, busc?1:0);
 }
 
 //------------------ ANROM ---------------------------
@@ -94,7 +149,7 @@ static void ANROMSync()
 
 void ANROM_Init(CartInfo *info)
 {
-  Latch_Init(info, ANROMSync, 0, 0x8000, 0xFFFF);
+  Latch_Init(info, ANROMSync, 0, 0x8000, 0xFFFF, 0, 0);
 }
 
 //------------------ Map 70 ---------------------------
@@ -108,7 +163,7 @@ static void M70Sync()
 
 void Mapper70_Init(CartInfo *info)
 {
-  Latch_Init(info, M70Sync, 0, 0x8000, 0xFFFF);
+  Latch_Init(info, M70Sync, 0, 0x8000, 0xFFFF, 0, 0);
 }
 
 //------------------ Map 152 ---------------------------
@@ -123,7 +178,7 @@ static void M152Sync()
 
 void Mapper152_Init(CartInfo *info)
 {
-  Latch_Init(info, M152Sync, 0, 0x8000, 0xFFFF);
+  Latch_Init(info, M152Sync, 0, 0x8000, 0xFFFF, 0, 0);
 }
 
 //------------------ Map 78 ---------------------------
@@ -138,7 +193,7 @@ static void M78Sync()
 
 void Mapper78_Init(CartInfo *info)
 {
-  Latch_Init(info, M78Sync, 0, 0x8000, 0xFFFF);
+  Latch_Init(info, M78Sync, 0, 0x8000, 0xFFFF, 0, 0);
 }
 
 //------------------ MHROM ---------------------------
@@ -150,13 +205,19 @@ static void MHROMSync(void)
 }
 
 void MHROM_Init(CartInfo *info)
-{ 
-  Latch_Init(info, MHROMSync, 0, 0x8000, 0xFFFF);
+{
+  Latch_Init(info, MHROMSync, 0, 0x8000, 0xFFFF, 0, 0);
 }
 
 void Mapper140_Init(CartInfo *info)
-{ 
-  Latch_Init(info, MHROMSync, 0, 0x6000, 0x7FFF);
+{
+  Latch_Init(info, MHROMSync, 0, 0x6000, 0x7FFF, 0, 0);
+}
+
+void Mapper240_Init(CartInfo *info)
+{
+  Latch_Init(info, MHROMSync, 0, 0x4020, 0x5FFF, 0, 0);
+  // need SRAM.
 }
 
 //------------------ Map 87 ---------------------------
@@ -165,12 +226,27 @@ static void M87Sync(void)
 {
   setprg16(0x8000,0);
   setprg16(0xC000,1);
-  setchr8(latche>>1);
+  setchr8(((latche>>1)&1)|((latche<<1)&2));
+//  setchr8(latche);
 }
 
 void Mapper87_Init(CartInfo *info)
-{ 
-  Latch_Init(info, M87Sync, ~0, 0x6000, 0xFFFF);
+{
+  Latch_Init(info, M87Sync, ~0, 0x6000, 0xFFFF, 0, 0);
+}
+
+//------------------ Map 101 ---------------------------
+
+static void M101Sync(void)
+{
+  setprg16(0x8000,0);
+  setprg16(0xC000,1);
+  setchr8(latche);
+}
+
+void Mapper101_Init(CartInfo *info)
+{
+  Latch_Init(info, M101Sync, ~0, 0x6000, 0x7FFF, 0, 0);
 }
 
 //------------------ Map 11 ---------------------------
@@ -182,15 +258,40 @@ static void M11Sync(void)
 }
 
 void Mapper11_Init(CartInfo *info)
-{ 
-  Latch_Init(info, M11Sync, 0, 0x8000, 0xFFFF);
+{
+  Latch_Init(info, M11Sync, 0, 0x8000, 0xFFFF, 0, 0);
 }
 
 void Mapper144_Init(CartInfo *info)
-{ 
-  Latch_Init(info, M11Sync, 0, 0x8001, 0xFFFF);
+{
+  Latch_Init(info, M11Sync, 0, 0x8001, 0xFFFF, 0, 0);
 }
 
+//------------------ Map 38 ---------------------------
+
+static void M38Sync(void)
+{
+  setprg32(0x8000,latche&3);
+  setchr8(latche>>2);
+}
+
+void Mapper38_Init(CartInfo *info)
+{
+  Latch_Init(info, M38Sync, 0, 0x7000, 0x7FFF, 0, 0);
+}
+
+//------------------ Map 36 ---------------------------
+
+static void M36Sync(void)
+{
+  setprg32(0x8000,latche>>4);
+  setchr8((latche)&0xF);
+}
+
+void Mapper36_Init(CartInfo *info)
+{
+  Latch_Init(info, M36Sync, 0, 0x8400, 0xfffe, 0, 0);
+}
 //------------------ UNROM ---------------------------
 
 static void UNROMSync(void)
@@ -202,7 +303,7 @@ static void UNROMSync(void)
 
 void UNROM_Init(CartInfo *info)
 {
-  Latch_Init(info, UNROMSync, 0, 0x8000, 0xFFFF);
+  Latch_Init(info, UNROMSync, 0, 0x8000, 0xFFFF, 0, 1);
 }
 
 //------------------ Map 93 ---------------------------
@@ -216,7 +317,7 @@ static void SSUNROMSync(void)
 
 void SUNSOFT_UNROM_Init(CartInfo *info)
 {
-  Latch_Init(info, SSUNROMSync, 0, 0x8000, 0xFFFF);
+  Latch_Init(info, SSUNROMSync, 0, 0x8000, 0xFFFF, 0, 0);
 }
 
 //------------------ Map 94 ---------------------------
@@ -230,7 +331,21 @@ static void M94Sync(void)
 
 void Mapper94_Init(CartInfo *info)
 {
-  Latch_Init(info, M94Sync, 0, 0x8000, 0xFFFF);
+  Latch_Init(info, M94Sync, 0, 0x8000, 0xFFFF, 0, 0);
+}
+
+//------------------ Map 180 ---------------------------
+
+static void M180Sync(void)
+{
+  setprg16(0x8000,0);
+  setprg16(0xc000,latche);
+  setchr8(0);
+}
+
+void Mapper180_Init(CartInfo *info)
+{
+  Latch_Init(info, M180Sync, 0, 0x8000, 0xFFFF, 0, 0);
 }
 
 //------------------ Map 107 ---------------------------
@@ -243,7 +358,49 @@ static void M107Sync(void)
 
 void Mapper107_Init(CartInfo *info)
 {
-  Latch_Init(info, M107Sync, ~0, 0x8000, 0xFFFF);
+  Latch_Init(info, M107Sync, ~0, 0x8000, 0xFFFF, 0, 0);
+}
+
+//------------------ Map 113 ---------------------------
+
+static void M113Sync(void)
+{
+  setprg32(0x8000,(latche>>3)&7);
+  setchr8(((latche>>3)&8)|(latche&7));
+//  setmirror(latche>>7); // only for HES 6in1
+}
+
+void Mapper113_Init(CartInfo *info)
+{
+  Latch_Init(info, M113Sync, 0, 0x4100, 0x7FFF, 0, 0);
+}
+
+//------------------ A65AS ---------------------------
+
+// actually, there is two cart in one... First have extra mirroring
+// mode (one screen) and 32K bankswitching, second one have only
+// 16 bankswitching mode and normal mirroring... But there is no any
+// correlations between modes and they can be used in one mapper code.
+
+static void BMCA65ASSync(void)
+{
+  if(latche&0x40)
+    setprg32(0x8000,(latche>>1)&0x0F);
+  else
+  {
+    setprg16(0x8000,((latche&0x30)>>1)|(latche&7));
+    setprg16(0xC000,((latche&0x30)>>1)|7);
+  }
+  setchr8(0);
+  if(latche&0x80)
+    setmirror(MI_0+(((latche>>5)&1)));
+  else
+    setmirror(((latche>>3)&1)^1);
+}
+
+void BMCA65AS_Init(CartInfo *info)
+{
+  Latch_Init(info, BMCA65ASSync, 0, 0x8000, 0xFFFF, 0, 0);
 }
 
 //------------------ NROM ---------------------------
@@ -251,16 +408,22 @@ void Mapper107_Init(CartInfo *info)
 #ifdef DEBUG_MAPPER
 static DECLFW(WriteHandler)
 {
- FCEU_printf("$%04x:$%02x\n",A,V);
+ FCEU_printf("bs %04x %02x\n",A,V);
+ CartBW(A,V);
 }
 #endif
 
 static void NROMPower(void)
 {
+  setprg8r(0x10,0x6000,0); // Famili BASIC (v3.0) need it (uses only 4KB), FP-BASIC uses 8KB
   setprg16(0x8000,0);
   setprg16(0xC000,~0);
   setchr8(0);
+
+  SetReadHandler(0x6000,0x7FFF,CartBR);
+  SetWriteHandler(0x6000,0x7FFF,CartBW);
   SetReadHandler(0x8000,0xFFFF,CartBR);
+
   #ifdef DEBUG_MAPPER
   SetWriteHandler(0x4020,0xFFFF,WriteHandler);
   #endif
@@ -269,4 +432,15 @@ static void NROMPower(void)
 void NROM_Init(CartInfo *info)
 {
   info->Power=NROMPower;
+  info->Close=LatchClose;
+
+  WRAMSIZE=8192;
+  WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);
+  SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);
+  if(info->battery)
+  {
+    info->SaveGame[0]=WRAM;
+    info->SaveGameLen[0]=WRAMSIZE;
+  }
+  AddExState(WRAM, WRAMSIZE, 0, "WRAM");
 }
index 7a1ed43..2d28bd0 100644 (file)
@@ -15,7 +15,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 #include "mapinc.h"
@@ -32,9 +32,9 @@ static SFORMAT DEI_StateRegs[]=
 
 static void Sync(void)
 {
+  int x;
   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]);
index 7e1d563..d2a9cb8 100644 (file)
@@ -1,56 +1,56 @@
-/* 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");
-}
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2005 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 latche;\r
+\r
+static void Sync(void)\r
+{\r
+  setprg16(0x8000,latche);\r
+  setprg16(0xC000,8);\r
+}\r
+\r
+static DECLFW(DREAMWrite)\r
+{\r
+  latche=V&7;\r
+  Sync();\r
+}\r
+\r
+static void DREAMPower(void)\r
+{\r
+  latche=0;\r
+  Sync();\r
+  setchr8(0);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x5020,0x5020,DREAMWrite);\r
+}\r
+\r
+static void Restore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void DreamTech01_Init(CartInfo *info)\r
+{\r
+  GameStateRestore=Restore;\r
+  info->Power=DREAMPower;\r
+  AddExState(&latche, 1, 0, "LATCH");\r
+}\r
diff --git a/boards/edu2000.c b/boards/edu2000.c
new file mode 100644 (file)
index 0000000..36dcb5d
--- /dev/null
@@ -0,0 +1,84 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2006 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 *WRAM=NULL;\r
+static uint8 reg;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&reg, 1, "REG"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setchr8(0);\r
+  setprg8r(0x10,0x6000,(reg&0xC0)>>6);\r
+  setprg32(0x8000,reg&0x1F);\r
+//  setmirror(((reg&0x20)>>5));\r
+}\r
+\r
+static DECLFW(UNLEDU2000HiWrite)\r
+{\r
+//  FCEU_printf("%04x:%02x\n",A,V);\r
+  reg=V;\r
+  Sync();\r
+}\r
+\r
+static void UNLEDU2000Power(void)\r
+{\r
+  setmirror(MI_0);\r
+  SetReadHandler(0x6000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x6000,0xFFFF,CartBW);\r
+  SetWriteHandler(0x8000,0xFFFF,UNLEDU2000HiWrite);\r
+  reg=0;\r
+  Sync();\r
+}\r
+\r
+static void UNLEDU2000Close(void)\r
+{\r
+  if(WRAM)\r
+    FCEU_gfree(WRAM);\r
+  WRAM=NULL;\r
+}\r
+\r
+static void UNLEDU2000Restore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void UNLEDU2000_Init(CartInfo *info)\r
+{\r
+  info->Power=UNLEDU2000Power;\r
+  info->Close=UNLEDU2000Close;\r
+  GameStateRestore=UNLEDU2000Restore;\r
+  WRAM=(uint8*)FCEU_gmalloc(32768);\r
+  SetupCartPRGMapping(0x10,WRAM,32768,1);\r
+  if(info->battery)\r
+  {\r
+  info->SaveGame[0]=WRAM;\r
+  info->SaveGameLen[0]=32768;\r
+  }\r
+  AddExState(WRAM, 32768, 0, "WRAM");\r
+  AddExState(StateRegs, ~0, 0, 0);\r
+}\r
index abf0859..c869680 100644 (file)
-/* 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");
-}
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2006 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+#include "mmc3.h"\r
+#include "../ines.h"\r
+\r
+static bool is_BMCFK23CA;\r
+static uint8 unromchr;\r
+static uint32 dipswitch;\r
+static uint8 *CHRRAM=NULL;\r
+static uint32 CHRRAMSize;\r
+\r
+static void BMCFK23CCW(uint32 A, uint8 V)\r
+{\r
+  if(EXPREGS[0]&0x40)\r
+    setchr8(EXPREGS[2]|unromchr);\r
+  else if(EXPREGS[0]&0x20) {\r
+    setchr1r(0x10, A, V);\r
+  }\r
+  else\r
+  {\r
+    uint16 base=(EXPREGS[2]&0x7F)<<3;\r
+    if(EXPREGS[3]&2)\r
+    {\r
+      int cbase=(MMC3_cmd&0x80)<<5;\r
+      setchr1(A,V|base);\r
+      setchr1(0x0000^cbase,DRegBuf[0]|base);\r
+      setchr1(0x0400^cbase,EXPREGS[6]|base);\r
+      setchr1(0x0800^cbase,DRegBuf[1]|base);\r
+      setchr1(0x0c00^cbase,EXPREGS[7]|base);\r
+    }\r
+    else\r
+      setchr1(A,V|base);\r
+  }\r
+}\r
+\r
+//some games are wired differently, and this will need to be changed.\r
+//all the WXN games require prg_bonus = 1, and cah4e3's multicarts require prg_bonus = 0\r
+//we'll populate this from a game database\r
+static int prg_bonus;\r
+static int prg_mask;\r
+\r
+//prg_bonus = 0\r
+//4-in-1 (FK23C8021)[p1][!].nes\r
+//4-in-1 (FK23C8033)[p1][!].nes\r
+//4-in-1 (FK23C8043)[p1][!].nes\r
+//4-in-1 (FK23Cxxxx, S-0210A PCB)[p1][!].nes\r
+\r
+//prg_bonus = 1\r
+//[m176]大富翁2-上海大亨.wxn.nes\r
+//[m176]宠物翡翠.fix.nes\r
+//[m176]格兰帝亚.wxn.nes\r
+//[m176]梦幻之星.wxn.nes\r
+//[m176]水浒神兽.fix.nes\r
+//[m176]西楚霸王.fix.nes\r
+//[m176]超级大富翁.wxn.nes\r
+//[m176]雄霸天下.wxn.nes\r
+\r
+//works as-is under virtuanes m176\r
+//[m176]三侠五义.wxn.nes\r
+//[m176]口袋金.fix.nes\r
+//[m176]爆笑三国.fix.nes\r
+\r
+//needs other tweaks\r
+//[m176]三国忠烈传.wxn.nes\r
+//[m176]破釜沉舟.fix.nes\r
+\r
+//PRG wrapper\r
+static void BMCFK23CPW(uint32 A, uint8 V)\r
+{\r
+  uint32 bank = (EXPREGS[1] & 0x1F);\r
+  uint32 hiblock = ((EXPREGS[0] & 8) << 4)|((EXPREGS[0] & 0x80) << 1)|(UNIFchrrama?((EXPREGS[2] & 0x40)<<3):0);\r
+  uint32 block = (EXPREGS[1] & 0x60) | hiblock;\r
+  uint32 extra = (EXPREGS[3] & 2);\r
+\r
+  if((EXPREGS[0]&7)==4)\r
+    setprg32(0x8000,EXPREGS[1]>>1);\r
+  else if ((EXPREGS[0]&7)==3)\r
+  {\r
+    setprg16(0x8000,EXPREGS[1]);\r
+    setprg16(0xC000,EXPREGS[1]);\r
+  }  \r
+  else\r
+  { \r
+    if(EXPREGS[0]&3)\r
+               {\r
+                       uint32 blocksize = (6)-(EXPREGS[0]&3);\r
+                       uint32 mask = (1<<blocksize)-1;\r
+                       V &= mask;\r
+                       //V &= 63; //? is this a good idea?\r
+                       V |= (EXPREGS[1]<<1);\r
+      setprg8(A,V);\r
+               }\r
+    else\r
+      setprg8(A,V & prg_mask);\r
+\r
+    if(EXPREGS[3]&2)\r
+    {\r
+      setprg8(0xC000,EXPREGS[4]);\r
+      setprg8(0xE000,EXPREGS[5]);\r
+    }\r
+  }\r
+       setprg8r(0x10,0x6000,A001B&3);\r
+}\r
+\r
+//PRG handler ($8000-$FFFF)\r
+static DECLFW(BMCFK23CHiWrite)\r
+{\r
+       if(EXPREGS[0]&0x40)\r