merge mappers from FCEU-mm
authornotaz <notasas@gmail.com>
Sun, 30 Sep 2012 00:28:18 +0000 (03:28 +0300)
committernotaz <notasas@gmail.com>
Sun, 30 Sep 2012 15:09:39 +0000 (18:09 +0300)
the CaH4e3's FCEU Ultra fork

194 files changed:
boards/01-222.c
boards/103.c
boards/106.c
boards/108.c
boards/112.c
boards/116.c
boards/117.c
boards/120.c
boards/121.c
boards/12in1.c [new file with mode: 0644]
boards/15.c
boards/151.c [new file with mode: 0644]
boards/156.c [moved from mappers/156.c with 88% similarity]
boards/164.c
boards/168.c [new file with mode: 0644]
boards/17.c [new file with mode: 0644]
boards/170.c [new file with mode: 0644]
boards/175.c
boards/176.c [deleted file]
boards/177.c
boards/178.c
boards/18.c [new file with mode: 0644]
boards/183.c
boards/185.c
boards/186.c
boards/187.c
boards/189.c
boards/193.c [new file with mode: 0644]
boards/199.c
boards/208.c
boards/222.c
boards/225.c [new file with mode: 0644]
boards/23.c
boards/235.c
boards/253.c
boards/34.c [new file with mode: 0644]
boards/3d-block.c
boards/411120-c.c
boards/43.c
boards/57.c
boards/603-5052.c
boards/68.c
boards/8157.c
boards/82.c [new file with mode: 0644]
boards/8237.c
boards/830118C.c
boards/88.c
boards/90.c
boards/91.c [new file with mode: 0644]
boards/95.c
boards/96.c [new file with mode: 0644]
boards/99.c [new file with mode: 0644]
boards/KS7012.c [moved from boards/179.c with 62% similarity]
boards/KS7013.c [new file with mode: 0644]
boards/KS7017.c [new file with mode: 0644]
boards/KS7030.c [new file with mode: 0644]
boards/KS7031.c [new file with mode: 0644]
boards/KS7032.c [moved from boards/ks7032.c with 78% similarity]
boards/KS7037.c [new file with mode: 0644]
boards/KS7057.c [new file with mode: 0644]
boards/Makefile
boards/SA-9602B.c [new file with mode: 0644]
boards/__dummy_mapper.c
boards/__serial.c [new file with mode: 0644]
boards/__serial.h [new file with mode: 0644]
boards/a9711.c [deleted file]
boards/a9746.c
boards/ac-08.c [new file with mode: 0644]
boards/addrlatch.c
boards/ax5705.c
boards/bandai.c
boards/bb.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
boards/cityfighter.c [new file with mode: 0644]
boards/copyfami_emu.c [new file with mode: 0644]
boards/copyfami_hwi.c [new file with mode: 0644]
boards/dance2000.c [new file with mode: 0644]
boards/datalatch.c
boards/deirom.c
boards/dream.c
boards/edu2000.c
boards/famicombox.c [new file with mode: 0644]
boards/fk23c.c
boards/ghostbusters63in1.c
boards/gs-2004.c
boards/gs-2013.c
boards/h2288.c
boards/karaoke.c
boards/kof97.c
boards/konami-qtai.c
boards/le05.c [new file with mode: 0644]
boards/lh32.c [new file with mode: 0644]
boards/lh53.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 [deleted file]
boards/n106.c
boards/n625092.c
boards/novel.c
boards/onebus.c
boards/pec-586.c [new file with mode: 0644]
boards/sachen.c
boards/sc-127.c
boards/sheroes.c
boards/sl1632.c
boards/smb2j.c
boards/subor.c
boards/super24.c
boards/supervision.c
boards/t-227-1.c
boards/t-262.c
boards/tengen.c
boards/tf-1201.c
boards/transformer.c [new file with mode: 0644]
boards/vrc7.c [new file with mode: 0644]
boards/yoko.c [new file with mode: 0644]
ines.c
ines.h
mappers/151.c [deleted file]
mappers/16.c [deleted file]
mappers/17.c [deleted file]
mappers/18.c [deleted file]
mappers/193.c [deleted file]
mappers/201.c
mappers/202.c
mappers/203.c
mappers/204.c
mappers/21.c
mappers/217.c
mappers/22.c
mappers/225.c [deleted file]
mappers/227.c
mappers/228.c
mappers/229.c
mappers/230.c
mappers/231.c
mappers/232.c
mappers/234.c
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/46.c
mappers/50.c
mappers/51.c
mappers/59.c
mappers/6.c
mappers/60.c [deleted file]
mappers/61.c
mappers/62.c
mappers/65.c
mappers/67.c
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 [deleted file]
mappers/80.c
mappers/82.c [deleted file]
mappers/83.c [deleted file]
mappers/85.c
mappers/86.c [deleted file]
mappers/89.c [deleted file]
mappers/91.c [deleted file]
mappers/92.c [deleted file]
mappers/97.c [deleted file]
mappers/99.c [deleted file]
mappers/Makefile
mappers/mapinc.h
mappers/mmc2and4.c
mappers/simple.c [deleted file]
unif.c
unif.h

index c0e7320..1ad4080 100644 (file)
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * TXC mappers, originally much complex banksitching\r
+ *\r
+ * 01-22111-000 (05-00002-010) (132, 22211) - MGC-001 Qi Wang\r
+ * 01-22110-000 (52S         )              - MGC-002 2-in-1 Gun\r
+ * 01-22111-100 (02-00002-010) (173       ) - MGC-008 Mahjong Block\r
+ *                             (079       ) - MGC-012 Poke Block\r
+ * 01-22110-200 (05-00002-010) (036       ) - MGC-014 Strike Wolf\r
+ * 01-22000-400 (05-00002-010) (036       ) - MGC-015 Policeman\r
+ * 01-22017-000 (05-PT017-080) (189       ) - MGC-017 Thunder Warrior\r
+ * 01-22270-000 (05-00002-010) (132, 22211) - MGC-xxx Creatom\r
+ * 01-22200-400 (------------) (079       ) - ET.03   F-15 City War\r
+ *                             (172       ) -         1991 Du Ma Racing\r
+ *\r
  */\r
 \r
 #include "mapinc.h"\r
index e25f5fc..16eb551 100644 (file)
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * FDS Conversion\r
+ *\r
  */\r
 \r
 #include "mapinc.h"\r
index 638dda9..8958d60 100644 (file)
@@ -15,7 +15,7 @@
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
  */\r
 \r
 #include "mapinc.h"\r
@@ -28,7 +28,7 @@ static uint32 WRAMSIZE;
 static SFORMAT StateRegs[]=\r
 {\r
   {&IRQa, 1, "IRQA"},\r
-  {&IRQCount, 4, "IRQCOUNT"},\r
+  {&IRQCount, 4, "IRQC"},\r
   {reg, 16, "REGS"},\r
   {0}\r
 };\r
@@ -84,7 +84,7 @@ static void M106Close(void)
   WRAM=NULL;\r
 }\r
 \r
-void M106CpuHook(int a)\r
+void FP_FASTAPASS(1) M106CpuHook(int a)\r
 {\r
   if(IRQa)\r
   {\r
index fc3aebd..59d91f2 100644 (file)
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * FDS Conversion\r
+ *\r
+ * Meikyuu Jin Dababa\r
+ * Bubble Bobble Kaiser\r
+ *\r
  */\r
 \r
 #include "mapinc.h"\r
@@ -37,8 +43,8 @@ static void Sync(void)
 \r
 static DECLFW(M108Write)\r
 {\r
-   reg=V;\r
-   Sync();\r
+  reg=V;\r
+  Sync();\r
 }\r
 \r
 static void M108Power(void)\r
@@ -46,7 +52,8 @@ static void M108Power(void)
   Sync();\r
   SetReadHandler(0x6000,0x7FFF,CartBR);\r
   SetReadHandler(0x8000,0xFFFF,CartBR);\r
-  SetWriteHandler(0x8FFF,0x8FFF,M108Write);\r
+  SetWriteHandler(0x8000,0x8FFF,M108Write); // regular 108\r
+  SetWriteHandler(0xF000,0xFFFF,M108Write); // simplified Kaiser BB Hack\r
 }\r
 \r
 static void StateRestore(int version)\r
index ccfd4f4..daf65ce 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
  * NTDEC, ASDER games
+ *
  */
 
 #include "mapinc.h"
index 3a21668..09d2a27 100644 (file)
@@ -15,8 +15,8 @@
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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
  * 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
+ * AV Mei Shao Nv Zhan Shi (aka AV Pretty Girl Fighting) (SL-12 PCB, Hunag-1, GAL dip: unk conf. SL-11A/SL-11B maskroms)\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
+ * Contra Fighter (603-5052 PCB, 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 IRQCount,IRQLatch,IRQa;\r
+static 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
+  {vrc2_chr, 8, "VRCC"},\r
+  {vrc2_prg, 2, "VRCP"},\r
+  {&vrc2_mirr, 1, "VRCM"},\r
+  {mmc3_regs, 10, "M3RG"},\r
+  {&mmc3_ctrl, 1, "M3CT"},\r
+  {&mmc3_mirr, 1, "M3MR"},\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
+  {mmc1_regs, 4, "M1RG"},\r
+  {&mmc1_buffer, 1, "M1BF"},\r
+  {&mmc1_shift, 1, "M1MR"},\r
   {0}\r
 };\r
 \r
@@ -174,7 +173,7 @@ static void Sync(void)
 \r
 static DECLFW(UNLSL12ModeWrite)\r
 {\r
-  printf("%04X:%02X\n",A,V);\r
+//  FCEU_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
@@ -194,11 +193,7 @@ static DECLFW(UNLSL12ModeWrite)
 \r
 static DECLFW(UNLSL12Write)\r
 {\r
-  printf("%04X:%02X\n",A,V);\r
-       if(A==0xA123)\r
-       {\r
-               int zzz=9;\r
-       }\r
+//  FCEU_printf("%04X:%02X\n",A,V);\r
   switch(mode & 3) {\r
    case 0: {\r
      if((A>=0xB000)&&(A<=0xE003))\r
@@ -272,7 +267,7 @@ static DECLFW(UNLSL12Write)
          mmc1_buffer = mmc1_shift = 0;\r
          switch(n) {\r
           case 0: SyncMIR();\r
-          case 2: SyncCHR(); \r
+          case 2: SyncCHR();\r
           case 3:\r
           case 1: SyncPRG();\r
          }\r
@@ -352,8 +347,3 @@ void UNLSL12_Init(CartInfo *info)
   GameStateRestore = StateRestore;\r
   AddExState(&StateRegs, ~0, 0, 0);\r
 }\r
-\r
-void Mapper116_Init(CartInfo *info)\r
-{\r
-       UNLSL12_Init(info);\r
-}\r
index b2348f0..61d9519 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include "mapinc.h"
@@ -28,19 +28,19 @@ static SFORMAT StateRegs[]=
   {&IRQa, 1, "IRQA"},
   {&IRQCount, 1, "IRQC"},
   {&IRQLatch, 1, "IRQL"},
-  {prgreg, 4, "PREGS"},
-  {chrreg, 8, "CREGS"},
+  {prgreg, 4, "PREG"},
+  {chrreg, 8, "CREG"},
   {&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);   
index ed681b9..cacd122 100644 (file)
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * FDS Conversion\r
+ *\r
  */\r
 \r
 #include "mapinc.h"\r
@@ -48,8 +51,7 @@ static void M120Power(void)
 {\r
   reg=0;\r
   Sync();\r
-  SetReadHandler(0x6000,0x7FFF,CartBR);\r
-  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetReadHandler(0x6000,0xFFFF,CartBR);\r
   SetWriteHandler(0x4100,0x5FFF,M120Write);\r
 }\r
 \r
index 63784f9..eed3007 100644 (file)
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\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
+ * MK4, MK6, A9711 board\r
+ * 6035052 seems to be the same too, but with prot array in reverse\r
+ * A9746  seems to be the same too, check\r
+ * 187 seems to be the same too, check (A98402 board)\r
+ *\r
  */\r
 \r
 #include "mapinc.h"\r
 #include "mmc3.h"\r
 \r
-static uint8 readbyte = 0;\r
-\r
-static DECLFW(M121Write)\r
+static void Sync()\r
 {\r
-//  FCEU_printf("write: %04x:%04x\n",A&0xE003,V);\r
-  if((A&0xF003)==0x8003)\r
+  switch(EXPREGS[5]&0x3F)\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
+    case 0x20: EXPREGS[7] = 1; EXPREGS[0]=EXPREGS[6]; break;\r
+    case 0x29: EXPREGS[7] = 1; EXPREGS[0]=EXPREGS[6]; break;\r
+    case 0x26: EXPREGS[7] = 0; EXPREGS[0]=EXPREGS[6]; break;\r
+    case 0x2B: EXPREGS[7] = 1; EXPREGS[0]=EXPREGS[6]; break;\r
+    case 0x2C: EXPREGS[7] = 1; if(EXPREGS[6]) EXPREGS[0]=EXPREGS[6]; break;\r
+    case 0x3F: EXPREGS[7] = 1; EXPREGS[0]=EXPREGS[6]; break;\r
+    case 0x28: EXPREGS[7] = 0; EXPREGS[1]=EXPREGS[6]; break;\r
+    case 0x2A: EXPREGS[7] = 0; EXPREGS[2]=EXPREGS[6]; break;\r
+    case 0x2F: break;\r
+    default:   EXPREGS[5] = 0; break;\r
   }\r
+}\r
+\r
+static void M121CW(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 M121PW(uint32 A, uint8 V)\r
+{\r
+  if(EXPREGS[5]&0x3F)\r
+  {\r
+//    FCEU_printf("prot banks: %02x %02x %02x %02x\n",V,EXPREGS[2],EXPREGS[1],EXPREGS[0]);\r
+    setprg8(A,V&0x3F);\r
+    setprg8(0xE000,EXPREGS[0]);\r
+    setprg8(0xC000,EXPREGS[1]);\r
+    setprg8(0xA000,EXPREGS[2]);\r
+  } \r
   else\r
   {\r
-//    FixMMC3PRG(MMC3_cmd);\r
-    MMC3_CMDWrite(A,V);\r
+//    FCEU_printf("gen banks: %04x %02x\n",A,V);\r
+    setprg8(A,V&0x3F);\r
+  }\r
+}\r
+\r
+static DECLFW(M121Write)\r
+{\r
+//  FCEU_printf("write: %04x:%04x\n",A&0xE003,V);\r
+  switch(A&0xE003)\r
+  {\r
+    case 0x8000: //EXPREGS[5] = 0;\r
+//                 FCEU_printf("gen: %02x\n",V);\r
+                 MMC3_CMDWrite(A,V);\r
+                 FixMMC3PRG(MMC3_cmd);\r
+                 break;\r
+    case 0x8001: EXPREGS[6] = ((V&1)<<5)|((V&2)<<3)|((V&4)<<1)|((V&8)>>1)|((V&0x10)>>3)|((V&0x20)>>5);\r
+//                 FCEU_printf("bank: %02x (%02x)\n",V,EXPREGS[6]);\r
+                 if(!EXPREGS[7]) Sync();\r
+                 MMC3_CMDWrite(A,V);\r
+                 FixMMC3PRG(MMC3_cmd);\r
+                 break;\r
+    case 0x8003: EXPREGS[5] = V;\r
+//                 EXPREGS[7] = 0;\r
+//                 FCEU_printf("prot: %02x\n",EXPREGS[5]);\r
+                 Sync();\r
+                 MMC3_CMDWrite(0x8000,V);\r
+                 FixMMC3PRG(MMC3_cmd);\r
+                 break;\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
+  EXPREGS[4] = 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
+//  FCEU_printf("read:  %04x->\n",A,EXPREGS[0]);\r
+  return EXPREGS[4];\r
 }\r
 \r
 static void M121Power(void)\r
 {\r
+  EXPREGS[5] = 0;\r
   GenMMC3Power();\r
-//  Write_IRQFM(0x4017,0x40);\r
   SetReadHandler(0x5000,0x5FFF,M121Read);\r
   SetWriteHandler(0x5000,0x5FFF,M121LoWrite);\r
   SetWriteHandler(0x8000,0x9FFF,M121Write);\r
@@ -86,6 +121,8 @@ static void M121Power(void)
 void Mapper121_Init(CartInfo *info)\r
 {\r
   GenMMC3_Init(info, 128, 256, 8, 0);\r
+  pwrap=M121PW;\r
+  cwrap=M121CW;\r
   info->Power=M121Power;\r
-  AddExState(EXPREGS, 2, 0, "EXPR");\r
+  AddExState(EXPREGS, 8, 0, "EXPR");\r
 }\r
diff --git a/boards/12in1.c b/boards/12in1.c
new file mode 100644 (file)
index 0000000..4a10a42
--- /dev/null
@@ -0,0 +1,79 @@
+/* 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * 7-in-1 Darkwing Duck, Snake, MagicBlock (PCB marked as "12 in 1")\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg[4];\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {reg, 4, "REGS"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+    uint8 bank = (reg[3]&3)<<3;\r
+    setchr4(0x0000, (reg[1]>>3)|(bank<<2));\r
+    setchr4(0x1000, (reg[2]>>3)|(bank<<2));\r
+    if(reg[3]&8)\r
+    {\r
+      setprg32(0x8000,((reg[2]&7)>>1)|bank);\r
+    }\r
+    else\r
+    {\r
+      setprg16(0x8000, (reg[1]&7)|bank);\r
+      setprg16(0xc000, 7|bank);\r
+    }\r
+    setmirror(((reg[3]&4)>>2)^1);\r
+}\r
+\r
+static DECLFW(BMC12IN1Write)\r
+{\r
+  switch(A)\r
+  {\r
+  case 0xafff: reg[0] = V; break;\r
+  case 0xbfff: reg[1] = V; break;\r
+  case 0xdfff: reg[2] = V; break;\r
+  case 0xefff: reg[3] = V; break;\r
+  }\r
+  Sync();\r
+}\r
+\r
+static void BMC12IN1Power(void)\r
+{\r
+  reg[0]=reg[1]=reg[2]=reg[3]=0;\r
+  Sync();\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0xFFFF,BMC12IN1Write);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void BMC12IN1_Init(CartInfo *info)\r
+{\r
+  info->Power=BMC12IN1Power;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
index 6405afa..b720cee 100644 (file)
@@ -15,7 +15,7 @@
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
  *\r
  */\r
 \r
@@ -64,7 +64,6 @@ static DECLFW(M15Write)
 {\r
   latchea=A;\r
   latched=V;\r
-       printf("%04X = %02X\n",A,V);\r
   Sync();\r
 }\r
 \r
diff --git a/boards/151.c b/boards/151.c
new file mode 100644 (file)
index 0000000..b4d2fb3
--- /dev/null
@@ -0,0 +1,64 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2012 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 regs[8];\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {regs, 8, "REGS"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setprg8(0x8000,regs[0]);\r
+  setprg8(0xA000,regs[2]);\r
+  setprg8(0xC000,regs[4]);\r
+  setprg8(0xE000,~0);\r
+  setchr4(0x0000,regs[6]);  \r
+  setchr4(0x1000,regs[7]);  \r
+}\r
+\r
+static DECLFW(M151Write)\r
+{\r
+  regs[(A >> 12)&7] = V;\r
+  Sync();\r
+}\r
+\r
+static void M151Power(void)\r
+{\r
+  Sync();\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0xFFFF,M151Write);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper151_Init(CartInfo *info)\r
+{\r
+  info->Power=M151Power;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
similarity index 88%
rename from mappers/156.c
rename to boards/156.c
index 8e40a19..06c57c6 100644 (file)
 #include "mapinc.h"\r
 \r
 static uint8 chrlo[8], chrhi[8], prg, mirr, mirrisused = 0;\r
-// uint8 *WRAM=NULL;\r
+static uint8 *WRAM=NULL;\r
 static uint32 WRAMSIZE;\r
 \r
 static SFORMAT StateRegs[]=\r
 {\r
   {&prg, 1, "PREG"},\r
-  {chrlo, 8, "CRLO"},\r
-  {chrhi, 8, "CRHI"},\r
+  {chrlo, 8, "CRGL"},\r
+  {chrhi, 8, "CRGH"},\r
   {&mirr, 1, "MIRR"},\r
   {0}\r
 };\r
@@ -77,26 +77,12 @@ static DECLFW(M156Write)
   }\r
 }\r
 \r
-static void M1566Reset()\r
-{\r
-       for(int i=0;i<8;i++)\r
-       {\r
-               chrlo[i]=0;\r
-               chrhi[i]=0;\r
-       }\r
-       prg=0;\r
-       mirr=0;\r
-       mirrisused = 0;\r
-}\r
-\r
 static void M156Power(void)\r
 {\r
   Sync();\r
   SetReadHandler(0x6000,0xFFFF,CartBR);\r
   SetWriteHandler(0x6000,0x7FFF,CartBW);\r
   SetWriteHandler(0xC000,0xCFFF,M156Write);\r
-\r
-       M1566Reset();\r
 }\r
 \r
 static void M156Close(void)\r
index 22589ec..26cb8bc 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * It seems that 162/163/164 mappers are the same mapper with just different
+ * mapper modes enabled or disabled in software or hardware, need more nanjing
+ * carts
  */
 
 #include "mapinc.h"
 
-static uint8 cmd, laststrobe, trigger;
-static uint8 DRegs[8];
+static uint8 laststrobe, trigger;
+static uint8 reg[8];
+static uint8 *WRAM=NULL;
+static uint32 WRAMSIZE;
+
+static void(*WSync)(void);
+
 static SFORMAT StateRegs[]=
 {
-  {&cmd, 1, "CMD"},
   {&laststrobe, 1, "STB"},
   {&trigger, 1, "TRG"},
-  {DRegs, 8, "DREG"},
+  {reg, 8, "REGS"},
   {0}
 };
 
+/*
+const EEPROM_interface eeprom_interface. =
+{
+       9,                                 // address bits 9
+       8,                                 // data bits    8
+       "*110",                    // read         1 10 aaaaaaaaa
+       "*101",                    // write        1 01 aaaaaaaaa dddddddd
+.      "*10000xxxxxxx",   // lock         1 00 00xxxxxxx
+       "*10011xxxxxxx",   // unlock       1 00 11xxxxxxx
+       1,
+       5
+};
+
+static const EEPROM_interface *intf;
+
+static int serial_count = 0;
+static u8  serial_buffer[SERIAL_BUFFER_LENGTH];
+
+static int eeprom_data_bits;
+static int eeprom_clock_count;
+static int eeprom_read_address;
+static u8  *eeprom_data;
+
+static int latch = 0;
+static int locked = 1;
+static int sending = 0;
+static int reset_line = ASSERT_LINE;
+static int clock_line = ASSERT_LINE;
+static int reset_delay;
+
+void EEPROM_Init(u8 *data, u8 bit)
+{
+       eeprom_data = data;
+       if(bit == 8)
+               intf = &eeprom_interface_93C46_8;
+       else
+               intf = &eeprom_interface_93C46_16;
+}
+
+u8 *EEPROM_GetData()
+{
+       return eeprom_data;
+}
+
+static int EEPROM_command_match(const char *buf, const char *cmd, int len)
+{
+       if ( cmd == 0 ) return 0;
+       if ( len == 0 ) return 0;
+
+       for (;len>0;)
+       {
+               char b = *buf;
+               char c = *cmd;
+
+               if ((b==0) || (c==0))
+                       return (b==c);
+
+               switch ( c )
+               {
+               case '0':
+               case '1':
+                       if (b != c)     return 0;
+               case 'X':
+               case 'x':
+                       buf++;
+                       len--;
+                       cmd++;
+                       break;
+
+               case '*':
+                       c = cmd[1];
+                       switch( c )
+                       {
+                       case '0':
+                       case '1':
+                               if (b == c)     {       cmd++;                  }
+                               else            {       buf++;  len--;  }
+                               break;
+                       default:        return 0;
+                       }
+               }
+       }
+       return (*cmd==0);
+}
+
+static void EEPROM_write(int bit)
+{
+       if (serial_count >= SERIAL_BUFFER_LENGTH-1)
+       {
+               return;
+       }
+
+       serial_buffer[serial_count++] = (bit ? '1' : '0');
+       serial_buffer[serial_count] = 0;
+
+       if ( (serial_count > intf->address_bits) &&
+             EEPROM_command_match((char*)serial_buffer,intf->cmd_read,(int)strlen((char*)serial_buffer)-intf->address_bits) )
+       {
+               int i,address;
+
+               address = 0;
+               for (i = serial_count-intf->address_bits;i < serial_count;i++)
+               {
+                       address <<= 1;
+                       if (serial_buffer[i] == '1') address |= 1;
+               }
+               if (intf->data_bits == 16)
+                       eeprom_data_bits = (eeprom_data[2*address+0] << 8) + eeprom_data[2*address+1];
+               else
+                       eeprom_data_bits = eeprom_data[address];
+               eeprom_read_address = address;
+               eeprom_clock_count = 0;
+               sending = 1;
+               serial_count = 0;
+       }
+       else if ( (serial_count > intf->address_bits) &&
+                  EEPROM_command_match((char*)serial_buffer,intf->cmd_erase,(int)strlen((char*)serial_buffer)-intf->address_bits) )
+       {
+               int i,address;
+
+               address = 0;
+               for (i = serial_count-intf->address_bits;i < serial_count;i++)
+               {
+                       address <<= 1;
+                       if (serial_buffer[i] == '1') address |= 1;
+               }
+
+               if (locked == 0)
+               {
+                       if (intf->data_bits == 16)
+                       {
+                               eeprom_data[2*address+0] = 0x00;
+                               eeprom_data[2*address+1] = 0x00;
+                       }
+                       else
+                               eeprom_data[address] = 0x00;
+               }
+               else
+               serial_count = 0;
+       }
+       else if ( (serial_count > (intf->address_bits + intf->data_bits)) &&
+                  EEPROM_command_match((char*)serial_buffer,intf->cmd_write,(int)strlen((char*)serial_buffer)-(intf->address_bits + intf->data_bits)) )
+       {
+               int i,address,data;
+
+               address = 0;
+               for (i = serial_count-intf->data_bits-intf->address_bits;i < (serial_count-intf->data_bits);i++)
+               {
+                       address <<= 1;
+                       if (serial_buffer[i] == '1') address |= 1;
+               }
+               data = 0;
+               for (i = serial_count-intf->data_bits;i < serial_count;i++)
+               {
+                       data <<= 1;
+                       if (serial_buffer[i] == '1') data |= 1;
+               }
+               if (locked == 0)
+               {
+                       if (intf->data_bits == 16)
+                       {
+                               eeprom_data[2*address+0] = data >> 8;
+                               eeprom_data[2*address+1] = data & 0xff;
+                       }
+                       else
+                               eeprom_data[address] = data;
+               }
+               else
+               serial_count = 0;
+       }
+       else if ( EEPROM_command_match((char*)serial_buffer,intf->cmd_lock,(int)strlen((char*)serial_buffer)) )
+       {
+               locked = 1;
+               serial_count = 0;
+       }
+       else if ( EEPROM_command_match((char*)serial_buffer,intf->cmd_unlock,(int)strlen((char*)serial_buffer)) )
+       {
+               locked = 0;
+               serial_count = 0;
+       }
+}
+
+static void EEPROM_reset()
+{
+       serial_count = 0;
+       sending = 0;
+       reset_delay = intf->reset_delay;
+}
+
+void EEPROM_set_cs_line(int state)
+{
+       reset_line = state;
+
+       if (reset_line != CLEAR_LINE)
+               EEPROM_reset();
+}
+
+void EEPROM_set_clock_line(int state)
+{
+       if (state == PULSE_LINE || (clock_line == CLEAR_LINE && state != CLEAR_LINE))
+       {
+               if (reset_line == CLEAR_LINE)
+               {
+                       if (sending)
+                       {
+                               if (eeprom_clock_count == intf->data_bits)
+                               {
+                                       if(intf->enable_multi_read)
+                                       {
+                                               eeprom_read_address = (eeprom_read_address + 1) & ((1 << intf->address_bits) - 1);
+                                               if (intf->data_bits == 16)
+                                                       eeprom_data_bits = (eeprom_data[2*eeprom_read_address+0] << 8) + eeprom_data[2*eeprom_read_address+1];
+                                               else
+                                                       eeprom_data_bits = eeprom_data[eeprom_read_address];
+                                               eeprom_clock_count = 0;
+                                       }
+                                       else
+                                       {
+                                               sending = 0;
+                                       }
+                               }
+                               eeprom_data_bits = (eeprom_data_bits << 1) | 1;
+                               eeprom_clock_count++;
+                       }
+                       else
+                               EEPROM_write(latch);
+               }
+       }
+
+       clock_line = state;
+}
+
+
+void EEPROM_write_bit(int bit)
+{
+       latch = bit;
+}
+
+int EEPROM_read_bit(void)
+{
+       int res;
+
+       if (sending)
+               res = (eeprom_data_bits >> intf->data_bits) & 1;
+       else
+       {
+               if (reset_delay > 0)
+               {
+                       reset_delay--;
+                       res = 0;
+               }
+               else
+                       res = 1;
+       }
+
+       return res;
+}
+*/
+
 static void Sync(void)
 {
-  setprg32(0x8000,(DRegs[0]<<4)|(DRegs[1]&0xF));
+  setprg8r(0x10,0x6000,0);
+  setprg32(0x8000,(reg[0]<<4)|(reg[1]&0xF));
+  setchr8(0);
 }
 
 static void StateRestore(int version)
 {
-  Sync();
+  WSync();
 }
 
 static DECLFR(ReadLow)
 {
   switch (A&0x7700)
   {
-    case 0x5100: return DRegs[2]; break;
+    case 0x5100: return reg[2]|reg[0]|reg[1]|reg[3]^0xff; break;
     case 0x5500: if(trigger)
-                   return DRegs[2];
+                   return reg[2]|reg[1]; // Lei Dian Huang Bi Ka Qiu Chuan Shuo (NJ046) may broke other games
                  else
                    return 0;
   }
   return 4;
 }
 
+static void M163HB(void)
+{
+    if(reg[1]&0x80)
+    {
+      if(scanline==239)
+      {
+        setchr4(0x0000,0);
+        setchr4(0x1000,0);
+      }
+      else if(scanline==127)
+      {
+        setchr4(0x0000,1);
+        setchr4(0x1000,1);
+      }
+/*
+      if(scanline>=127)     // Hu Lu Jin Gang (NJ039) (Ch) [!] don't like it
+      {
+        setchr4(0x0000,1);
+        setchr4(0x1000,1);
+      }
+      else
+      {
+        setchr4(0x0000,0);
+        setchr4(0x1000,0);
+      }
+*/      
+    }
+}
+
 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;
+    case 0x5100: reg[0]=V; WSync(); break;
+    case 0x5000: reg[1]=V; WSync(); break;
+    case 0x5300: reg[2]=V; break;
+    case 0x5200: reg[3]=V; WSync(); break;
   }
 }
 
+static void Power(void)
+{
+  memset(reg,0,8);
+  reg[1]=0xFF;
+  SetWriteHandler(0x5000,0x5FFF,Write);
+  SetReadHandler(0x6000,0xFFFF,CartBR);
+  SetWriteHandler(0x6000,0x7FFF,CartBW);
+  WSync();
+}
+
+static void Close(void)
+{
+  if(WRAM)
+    FCEU_gfree(WRAM);
+  WRAM=NULL;
+}
+
+void Mapper164_Init(CartInfo *info)
+{
+  info->Power=Power;
+  info->Close=Close;
+  WSync = Sync;
+
+  WRAMSIZE = 8192;
+  WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);
+  SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);
+  AddExState(WRAM, WRAMSIZE, 0, "WRAM");
+
+  if(info->battery)
+  {
+    info->SaveGame[0]=WRAM;
+    info->SaveGameLen[0]=WRAMSIZE;
+  }
+
+  GameStateRestore=StateRestore;
+  AddExState(&StateRegs, ~0, 0, 0);
+}
+
 static DECLFW(Write2)
 {
   if(A==0x5101)
@@ -78,83 +415,97 @@ static DECLFW(Write2)
   else
   switch (A&0x7300)
   {
-    case 0x5200: DRegs[0]=V; Sync(); break;
-    case 0x5000: DRegs[1]=V; Sync(); if(!(DRegs[1]&0x80)&&(scanline<128)) setchr8(0); break;
-    case 0x5300: DRegs[2]=V; break;
+    case 0x5200: reg[0]=V; WSync(); break;
+    case 0x5000: reg[1]=V; WSync(); if(!(reg[1]&0x80)&&(scanline<128)) setchr8(0); /* setchr8(0); */ break;
+    case 0x5300: reg[2]=V; break;
+    case 0x5100: reg[3]=V; WSync(); break;
   }
 }
 
-static uint8 WRAM[8192];
-static DECLFR(AWRAM)
+static void Power2(void)
 {
-  return(WRAM[A-0x6000]);
+  memset(reg,0,8);
+  laststrobe=1;
+  SetReadHandler(0x5000,0x5FFF,ReadLow);
+  SetWriteHandler(0x5000,0x5FFF,Write2);
+  SetReadHandler(0x6000,0xFFFF,CartBR);
+  SetWriteHandler(0x6000,0x7FFF,CartBW);
+  WSync();
 }
 
-static DECLFW(BWRAM)
+void Mapper163_Init(CartInfo *info)
 {
-  WRAM[A-0x6000]=V;
+  info->Power=Power2;
+  info->Close=Close;
+  WSync = Sync;
+  GameHBIRQHook=M163HB;
+
+  WRAMSIZE = 8192;
+  WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);
+  SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);
+  AddExState(WRAM, WRAMSIZE, 0, "WRAM");
+
+  if(info->battery)
+  {
+    info->SaveGame[0]=WRAM;
+    info->SaveGameLen[0]=WRAMSIZE;
+  }
+  GameStateRestore=StateRestore;
+  AddExState(&StateRegs, ~0, 0, 0);
 }
 
-static void Power(void)
+static void Sync3(void)
 {
-  memset(DRegs,0,8);
-  DRegs[1]=0xFF;
-  cmd=0;
-  SetReadHandler(0x8000,0xFFFF,CartBR);
-  SetWriteHandler(0x4020,0x5FFF,Write);
-  SetReadHandler(0x6000,0x7FFF,AWRAM);
-  SetWriteHandler(0x6000,0x7FFF,BWRAM);
   setchr8(0);
-  Sync();
+  setprg8r(0x10,0x6000,0);
+  switch(reg[3]&7){
+    case 0:
+    case 2: setprg32(0x8000,(reg[0]&0xc)|(reg[1]&2)|((reg[2]&0xf)<<4)); break;
+    case 1:
+    case 3: setprg32(0x8000,(reg[0]&0xc)|(reg[2]&0xf)<<4); break;
+    case 4: 
+    case 6: setprg32(0x8000,(reg[0]&0xe)|((reg[1]>>1)&1)|((reg[2]&0xf)<<4)); break;
+    case 5:
+    case 7: setprg32(0x8000,(reg[0]&0xf)|((reg[2]&0xf)<<4)); break;
+  }
 }
 
-static void M163HB(void)
+static DECLFW(Write3)
 {
-    if(DRegs[1]&0x80)
-    {
-      if(scanline==239)
-      {
-        setchr4(0x0000,0);
-        setchr4(0x1000,0);
-      }
-      else if(scanline==127)
-      {
-        setchr4(0x0000,1);
-        setchr4(0x1000,1);
-      }
-    }
+//  FCEU_printf("bs %04x %02x\n",A,V);
+  reg[(A>>8)&3]=V;
+  WSync();
 }
 
-static void Power2(void)
+static void Power3(void)
 {
-  memset(DRegs,0,8);
-  DRegs[1]=0xFF;
-  laststrobe=1;
-  cmd=0;
-  SetReadHandler(0x8000,0xFFFF,CartBR);
-  SetWriteHandler(0x4020,0x5FFF,Write2);
-  SetReadHandler(0x6000,0x7FFF,AWRAM);
-  SetWriteHandler(0x6000,0x7FFF,BWRAM);
-  SetReadHandler(0x5000,0x5FFF,ReadLow);
-  setchr8(0);
-  Sync();
+  reg[0]=3;
+  reg[1]=0;
+  reg[2]=0;
+  reg[3]=7;
+  SetWriteHandler(0x5000,0x5FFF,Write3);
+  SetReadHandler(0x6000,0xFFFF,CartBR);
+  SetWriteHandler(0x6000,0x7FFF,CartBW);
+  WSync();
 }
 
-void Mapper164_Init(CartInfo *info)
+void UNLFS304_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;
-}
+  info->Power=Power3;
+  info->Close=Close;
+  WSync = Sync3;
+  
+  WRAMSIZE = 8192;
+  WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);
+  SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);
+  AddExState(WRAM, WRAMSIZE, 0, "WRAM");
 
-void Mapper163_Init(CartInfo *info)
-{
-  info->Power=Power2;
-  GameHBIRQHook=M163HB;
+  if(info->battery)
+  {
+    info->SaveGame[0]=WRAM;
+    info->SaveGameLen[0]=WRAMSIZE;
+  }
+  
   GameStateRestore=StateRestore;
   AddExState(&StateRegs, ~0, 0, 0);
-  AddExState(WRAM, 8192, 0, "WRAM");
 }
diff --git a/boards/168.c b/boards/168.c
new file mode 100644 (file)
index 0000000..170521a
--- /dev/null
@@ -0,0 +1,89 @@
+/* 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * RacerMate Chalenge II\r
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg;\r
+static uint8 *CHRRAM=NULL;\r
+static uint32 CHRRAMSIZE;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&reg, 1, "REGS"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setchr4r(0x10,0x0000,0);\r
+  setchr4r(0x10,0x1000,reg&0x0f);\r
+  setprg16(0x8000,reg>>6);\r
+  setprg16(0xc000,~0);\r
+}\r
+\r
+static DECLFW(M168Write)\r
+{\r
+  reg=V;\r
+  Sync();\r
+}\r
+\r
+static DECLFW(M168Dummy)\r
+{\r
+}\r
+\r
+static void M168Power(void)\r
+{\r
+  reg=0;\r
+  Sync();\r
+  SetWriteHandler(0x4020,0x7fff,M168Dummy);\r
+  SetWriteHandler(0xB000,0xB000,M168Write);\r
+  SetWriteHandler(0xF000,0xF000,M168Dummy);\r
+  SetWriteHandler(0xF080,0xF080,M168Dummy);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+}\r
+\r
+static void MNNNClose(void)\r
+{\r
+  if(CHRRAM)\r
+    FCEU_gfree(CHRRAM);\r
+  CHRRAM=NULL;\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper168_Init(CartInfo *info)\r
+{\r
+  info->Power=M168Power;\r
+  info->Close=MNNNClose;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+\r
+  CHRRAMSIZE=8192*8;\r
+  CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSIZE);\r
+  SetupCartCHRMapping(0x10,CHRRAM,CHRRAMSIZE,1);\r
+  AddExState(CHRRAM, CHRRAMSIZE, 0, "CRAM");\r
+\r
+}\r
diff --git a/boards/17.c b/boards/17.c
new file mode 100644 (file)
index 0000000..a08caaa
--- /dev/null
@@ -0,0 +1,122 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2012 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * FFE Copier Mapper\r
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 preg[4], creg[8];\r
+static uint8 IRQa, mirr;\r
+static int32 IRQCount, IRQLatch;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {preg, 4, "PREG"},\r
+  {creg, 8, "CREG"},\r
+  {&mirr, 1, "MIRR"},\r
+  {&IRQa, 1, "IRQA"},\r
+  {&IRQCount, 4, "IRQC"},\r
+  {&IRQLatch, 4, "IRQL"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  int i;\r
+  for(i=0; i<8; i++) setchr1(i<<10,creg[i]);\r
+  setprg8(0x8000,preg[0]);\r
+  setprg8(0xA000,preg[1]);\r
+  setprg8(0xC000,preg[2]);\r
+  setprg8(0xE000,preg[3]);\r
+  switch(mirr) {\r
+    case 0: setmirror(MI_0); break;\r
+    case 1: setmirror(MI_1); break;\r
+    case 2: setmirror(MI_H); break;\r
+    case 3: setmirror(MI_V); break;\r
+  }\r
+}\r
+\r
+static DECLFW(M17WriteMirr)\r
+{\r
+  mirr = ((A << 1) & 2)|((V >> 4) & 1);\r
+  Sync();\r
+}\r
+\r
+static DECLFW(M17WriteIRQ)\r
+{\r
+  switch(A) {\r
+    case 0x4501: IRQa=0; X6502_IRQEnd(FCEU_IQEXT); break;\r
+    case 0x4502: IRQCount&=0xFF00; IRQCount|=V; break;\r
+    case 0x4503: IRQCount&=0x00FF; IRQCount|=V<<8; IRQa=1; break;\r
+  }\r
+}\r
+\r
+static DECLFW(M17WritePrg)\r
+{\r
+  preg[A & 3] = V;\r
+  Sync();\r
+}\r
+\r
+static DECLFW(M17WriteChr)\r
+{\r
+  creg[A & 7] = V;\r
+  Sync();\r
+}\r
+\r
+static void M17Power(void)\r
+{\r
+  preg[3] = ~0;\r
+  Sync();\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x42FE,0x42FF,M17WriteMirr);\r
+  SetWriteHandler(0x4500,0x4503,M17WriteIRQ);\r
+  SetWriteHandler(0x4504,0x4507,M17WritePrg);\r
+  SetWriteHandler(0x4510,0x4517,M17WriteChr);\r
+}\r
+\r
+static void FP_FASTAPASS(1) M17IRQHook(int a)\r
+{\r
+  if(IRQa)\r
+  {\r
+    IRQCount+=a;\r
+    if(IRQCount>=0x10000)\r
+    {\r
+      X6502_IRQBegin(FCEU_IQEXT);\r
+      IRQa=0;\r
+      IRQCount=0;\r
+    }\r
+  }\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper17_Init(CartInfo *info)\r
+{\r
+  info->Power=M17Power;\r
+  GameHBIRQHook=M17IRQHook;\r
+  GameStateRestore=StateRestore;\r
+\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
+\r
diff --git a/boards/170.c b/boards/170.c
new file mode 100644 (file)
index 0000000..7694fe0
--- /dev/null
@@ -0,0 +1,68 @@
+/* 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&reg, 1, "REGS"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setprg16(0x8000, 0);\r
+  setprg16(0xc000,~0);\r
+  setchr8(0);\r
+}\r
+\r
+static DECLFW(M170ProtW)\r
+{\r
+  reg = V << 1 & 0x80;\r
+}\r
+\r
+static DECLFR(M170ProtR)\r
+{\r
+  return reg | (X.DB & 0x7F);\r
+}\r
+\r
+static void M170Power(void)\r
+{\r
+  Sync();\r
+  SetWriteHandler(0x6502,0x6502,M170ProtW);\r
+  SetWriteHandler(0x7000,0x7000,M170ProtW);\r
+  SetReadHandler(0x7001,0x7001,M170ProtR);\r
+  SetReadHandler(0x7777,0x7777,M170ProtR);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper170_Init(CartInfo *info)\r
+{\r
+  info->Power=M170Power;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
index 2830584..13bbddd 100644 (file)
@@ -15,7 +15,7 @@
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
  */\r
 \r
 #include "mapinc.h"\r
diff --git a/boards/176.c b/boards/176.c
deleted file mode 100644 (file)
index 0830df8..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-/* 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
index 6bc81b9..e8e758e 100644 (file)
@@ -15,7 +15,7 @@
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
  */\r
 \r
 #include "mapinc.h"\r
index 19e1b8d..0c6892f 100644 (file)
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ * \r
+ * San Guo Zhong Lie Zhuan (Ch)\r
+ * win200, etc\r
+ *\r
  */\r
 \r
 #include "mapinc.h"\r
 \r
-static uint8 reg[3];\r
+static uint8 reg[4];\r
 static uint8 *WRAM=NULL;\r
 static uint32 WRAMSIZE;\r
 \r
 static SFORMAT StateRegs[]=\r
 {\r
-  {reg, 3, "REGS"},\r
+  {reg, 4, "REGS"},\r
   {0}\r
 };\r
 \r
 static void Sync(void)\r
 {\r
-  setmirror(reg[0]);\r
+  uint8 bank = (reg[2]&3)<<3;\r
+  setmirror((reg[0]&1)^1);\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
+  if(reg[0]&2)\r
+  {\r
+    setprg16(0x8000,(reg[1]&7)|bank);\r
+    setprg16(0xC000,((~0)&7)|bank);\r
+  }\r
+  else\r
+  {\r
+    setprg16(0x8000,(reg[1]&6)|bank);\r
+    setprg16(0xC000,(reg[1]&6)|bank|1);\r
+  }\r
 }\r
 \r
-static DECLFW(M178Write2)\r
+static DECLFW(M178Write)\r
 {\r
-  reg[2]=(V<<2);\r
+  reg[A&3]=V;\r
   Sync();\r
 }\r
 \r
 static void M178Power(void)\r
 {\r
-  reg[0]=1; reg[1]=0; reg[2]=0;\r
+  reg[0]=1;\r
+  reg[1]=0;\r
+  reg[2]=0;\r
+  reg[3]=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
+  SetWriteHandler(0x4800,0x4803,M178Write);\r
 }\r
 \r
 static void M178Close(void)\r
diff --git a/boards/18.c b/boards/18.c
new file mode 100644 (file)
index 0000000..4b07474
--- /dev/null
@@ -0,0 +1,121 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2012 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 preg[4], creg[8];\r
+static uint8 IRQa, mirr;\r
+static int32 IRQCount, IRQLatch;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {preg, 4, "PREG"},\r
+  {creg, 8, "CREG"},\r
+  {&mirr, 1, "MIRR"},\r
+  {&IRQa, 1, "IRQA"},\r
+  {&IRQCount, 4, "IRQC"},\r
+  {&IRQLatch, 4, "IRQL"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  int i;\r
+  for(i=0; i<8; i++) setchr1(i<<10,creg[i]);\r
+  setprg8(0x8000,preg[0]);\r
+  setprg8(0xA000,preg[1]);\r
+  setprg8(0xC000,preg[2]);\r
+  setprg8(0xE000,~0);\r
+  if(mirr & 2)\r
+    setmirror(MI_0);\r
+  else\r
+    setmirror(mirr & 1);\r
+}\r
+\r
+static DECLFW(M18WriteIRQ)\r
+{\r
+  switch(A & 0xF003) {\r
+    case 0xE000: IRQLatch&=0xFFF0; IRQLatch|=(V&0x0f)<<0x0;break;\r
+    case 0xE001: IRQLatch&=0xFF0F; IRQLatch|=(V&0x0f)<<0x4; break;\r
+    case 0xE002: IRQLatch&=0xF0FF; IRQLatch|=(V&0x0f)<<0x8; break;\r
+    case 0xE003: IRQLatch&=0x0FFF; IRQLatch|=(V&0x0f)<<0xC; break;\r
+    case 0xF000: IRQCount=IRQLatch; break;\r
+    case 0xF001: IRQa=V&1; X6502_IRQEnd(FCEU_IQEXT); break;\r
+    case 0xF002: mirr = V&3; Sync(); break;\r
+  }\r
+}\r
+\r
+static DECLFW(M18WritePrg)\r
+{\r
+  uint32 i = ((A >> 1) & 1)|((A - 0x8000) >> 11);\r
+  preg[i] &= (0xF0) >> ((A & 1) << 2);\r
+  preg[i] |= (V & 0xF) << ((A & 1) << 2);\r
+  Sync();\r
+}\r
+\r
+static DECLFW(M18WriteChr)\r
+{\r
+  uint32 i = ((A >> 1) & 1)|((A - 0xA000) >> 11);\r
+  creg[i] &= (0xF0) >> ((A & 1) << 2);\r
+  creg[i] |= (V & 0xF) << ((A & 1) << 2);\r
+  Sync();\r
+}\r
+\r
+static void M18Power(void)\r
+{\r
+  preg[0] = 0;\r
+  preg[1] = 1;\r
+  preg[2] = ~1;\r
+  preg[3] = ~0;\r
+  Sync();\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0x9FFF,M18WritePrg);\r
+  SetWriteHandler(0xA000,0xDFFF,M18WriteChr);\r
+  SetWriteHandler(0xE000,0xFFFF,M18WriteIRQ);\r
+}\r
+\r
+static void FP_FASTAPASS(1) M18IRQHook(int a)\r
+{\r
+  if(IRQa && IRQCount)\r
+  {\r
+    IRQCount-=a;\r
+    if(IRQCount<=0)\r
+    {\r
+      X6502_IRQBegin(FCEU_IQEXT);\r
+      IRQCount=0;\r
+      IRQa=0;\r
+    }\r
+  }\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper18_Init(CartInfo *info)\r
+{\r
+  info->Power=M18Power;\r
+  MapIRQHook=M18IRQHook;\r
+  GameStateRestore=StateRestore;\r
+\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
+\r
index bf0b7c0..8d4f79b 100644 (file)
@@ -15,7 +15,7 @@
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
  *\r
  * Gimmick Bootleg (VRC4 mapper)\r
  */\r
@@ -32,8 +32,8 @@ static SFORMAT StateRegs[]=
 {\r
   {prg, 4, "PRG"},\r
   {chr, 8, "CHR"},\r
-  {&IRQCount, 1, "IRQCOUNT"},\r
-  {&IRQPre, 1, "IRQPRE"},\r
+  {&IRQCount, 1, "IRQC"},\r
+  {&IRQPre, 1, "IRQP"},\r
   {&IRQa, 1, "IRQA"},\r
   {0}\r
 };\r
@@ -64,7 +64,7 @@ static DECLFW(M183Write)
 {\r
   if(((A&0xF80C)>=0xB000)&&((A&0xF80C)<=0xE00C))\r
   {\r
-    uint8 index=(((A>>11)-6)|(A>>3))&7;\r
+    int index=(((A>>11)-6)|(A>>3))&7;\r
     chr[index]=(chr[index]&(0xF0>>(A&4)))|((V&0x0F)<<(A&4));\r
     SyncChr();\r
   }\r
index b865a8f..7ea86bb 100644 (file)
@@ -15,7 +15,7 @@
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
  *\r
  */\r
 \r
@@ -88,12 +88,12 @@ static void MRestore(int version)
 \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
+  int x;\r
   for(x=0;x<8192;x++)\r
      DummyCHR[x]=0xff;\r
   SetupCartCHRMapping(0x10,DummyCHR,8192,0);\r
@@ -102,12 +102,12 @@ void Mapper185_Init(CartInfo *info)
 \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
+  int x;\r
   for(x=0;x<8192;x++)\r
      DummyCHR[x]=0xff;\r
   SetupCartCHRMapping(0x10,DummyCHR,8192,0);\r
index 4976265..1713050 100644 (file)
@@ -15,7 +15,7 @@
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
  *\r
  * Family Study Box by Fukutake Shoten\r
  */\r
@@ -29,7 +29,7 @@ static uint8 regs[4];
 static SFORMAT StateRegs[]=\r
 {\r
   {regs, 4, "DREG"},\r
-  {SWRAM, 2816, "SWRAM"},\r
+  {SWRAM, 2816, "SWRM"},\r
   {0}\r
 };\r
 \r
index 0f49748..0852cba 100644 (file)
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * A98402 board, A9711, A9746 similar\r
+ * King of Fighters 96, The (Unl), Street Fighter Zero 2 (Unl)\r
+ * \r
  */\r
 \r
 #include "mapinc.h"\r
@@ -35,7 +39,12 @@ static void M187PW(uint32 A, uint8 V)
   {\r
     uint8 bank=EXPREGS[0]&0x1F;\r
     if(EXPREGS[0]&0x20)\r
-      setprg32(0x8000,bank>>2);\r
+    {\r
+      if(EXPREGS[0]&0x40)\r
+        setprg32(0x8000,bank>>2);\r
+      else\r
+        setprg32(0x8000,bank>>1); // hacky hacky! two mappers in one! need real hw carts to test\r
+    }\r
     else\r
     {\r
       setprg16(0x8000,bank);\r
@@ -48,28 +57,19 @@ static void M187PW(uint32 A, uint8 V)
 \r
 static DECLFW(M187Write8000)\r
 {\r
-  EXPREGS[2]=1;\r
+  EXPREGS[1]=1;\r
   MMC3_CMDWrite(A,V);\r
 }\r
 \r
 static DECLFW(M187Write8001)\r
 {\r
-  if(EXPREGS[2])\r
+  if(EXPREGS[1])\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
+  if((A==0x5000)||(A==0x6000))\r
   {\r
     EXPREGS[0]=V;\r
     FixMMC3PRG(MMC3_cmd);\r
@@ -84,13 +84,12 @@ static DECLFR(M187Read)
 \r
 static void M187Power(void)\r
 {\r
-  EXPREGS[0]=EXPREGS[1]=EXPREGS[2]=0;\r
+  EXPREGS[0]=EXPREGS[1]=0;\r
   GenMMC3Power();\r
   SetReadHandler(0x5000,0x5FFF,M187Read);\r
-  SetWriteHandler(0x5000,0x5FFF,M187WriteLo);\r
+  SetWriteHandler(0x5000,0x6FFF,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
index ff045a5..48393f9 100644 (file)
@@ -15,7 +15,7 @@
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
  */\r
 \r
 #include "mapinc.h"\r
@@ -23,7 +23,7 @@
 \r
 static void M189PW(uint32 A, uint8 V)\r
 {\r
-  setprg32(0x8000,EXPREGS[0]&3);\r
+  setprg32(0x8000,EXPREGS[0]&7);\r
 }\r
 \r
 static DECLFW(M189Write)\r
diff --git a/boards/193.c b/boards/193.c
new file mode 100644 (file)
index 0000000..e17323a
--- /dev/null
@@ -0,0 +1,80 @@
+/* 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * MEGA-SOFT WAR IN THE GULF\r
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg[8];\r
+static uint8 mirror, cmd, bank;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&cmd, 1, "CMD"},\r
+  {&mirror, 1, "MIRR"},\r
+  {&bank, 1, "BANK"},\r
+  {reg, 8, "REGS"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setmirror(mirror^1);\r
+  setprg8(0x8000,reg[3]);\r
+  setprg8(0xA000,0xD);\r
+  setprg8(0xC000,0xE);\r
+  setprg8(0xE000,0xF);\r
+  setchr4(0x0000,reg[0]>>2);\r
+  setchr2(0x1000,reg[1]>>1);\r
+  setchr2(0x1800,reg[2]>>1);\r
+}\r
+\r
+static DECLFW(M193Write)\r
+{\r
+  reg[A&3]=V;\r
+  Sync();\r
+}\r
+\r
+static void M193Power(void)\r
+{\r
+  bank=0;\r
+  Sync();\r
+  SetWriteHandler(0x6000,0x6003,M193Write);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0xFFFF,CartBW);\r
+}\r
+\r
+static void M193Reset(void)\r
+{\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper193_Init(CartInfo *info)\r
+{\r
+  info->Reset=M193Reset;\r
+  info->Power=M193Power;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
index ed21278..3302dc6 100644 (file)
@@ -15,7 +15,7 @@
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
  *\r
  * Dragon Ball Z 2 - Gekishin Freeza! (C)\r
  * Dragon Ball Z Gaiden - Saiya Jin Zetsumetsu Keikaku (C)\r
@@ -26,7 +26,8 @@
 #include "mapinc.h"\r
 #include "mmc3.h"\r
 \r
-static uint8 *CHRRAM=NULL; // and here too\r
+static uint8 *CHRRAM=NULL;\r
+static uint32 CHRRAMSIZE;\r
 \r
 static void M199PW(uint32 A, uint8 V)\r
 {\r
@@ -60,7 +61,6 @@ static DECLFW(M199Write)
 {\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
@@ -82,16 +82,26 @@ static void M199Power(void)
   SetWriteHandler(0x8000,0xFFFF,M199Write);\r
 }\r
 \r
+static void M199Close(void)\r
+{\r
+  if(CHRRAM)\r
+    FCEU_gfree(CHRRAM);\r
+  CHRRAM=NULL;\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
+  info->Close=M199Close;\r
+\r
+  CHRRAMSIZE=8192;\r
+  CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSIZE);\r
+  SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1);\r
+  AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR");\r
+\r
   AddExState(EXPREGS, 4, 0, "EXPR");\r
 }\r
index 3bbb34d..a7c8ac9 100644 (file)
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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
+  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
index e230751..a1da139 100644 (file)
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
  * (VRC4 mapper)\r
+ *\r
  */\r
 \r
 #include "mapinc.h"\r
 \r
-static uint8 IRQCount;\r
+static uint8 IRQCount;//, IRQPre;\r
 static uint8 IRQa;\r
 static uint8 prg_reg[2];\r
 static uint8 chr_reg[8];\r
@@ -52,12 +54,12 @@ static void M222IRQ(void)
 \r
 static void Sync(void)\r
 {\r
-  int i;\r
   setprg8(0x8000,prg_reg[0]);\r
   setprg8(0xA000,prg_reg[1]);\r
+  int i;\r
   for(i=0; i<8; i++)\r
-     setchr1(i<<10,chr_reg[i]);\r
-  setmirror(mirr^1);\r
+     setchr1(i<<10,chr_reg[i]);     \r
+  setmirror(mirr^1);   \r
 }\r
 \r
 static DECLFW(M222Write)\r
diff --git a/boards/225.c b/boards/225.c
new file mode 100644 (file)
index 0000000..0c86edf
--- /dev/null
@@ -0,0 +1,99 @@
+/* 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ * \r
+ * PCB-018 board, discrete multigame cart 110-in-1\r
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 prot[4], prg, mode, chr, mirr;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {prot, 4, "PROT"},\r
+  {&prg, 1, "PRG"},\r
+  {&chr, 1, "CHR"},\r
+  {&mode, 1, "MODE"},\r
+  {&mirr, 1, "MIRR"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  if(mode)\r
+  {\r
+    setprg16(0x8000,prg);\r
+    setprg16(0xC000,prg);\r
+  }\r
+  else\r
+    setprg32(0x8000,prg>>1);\r
+  setchr8(chr);\r
+  setmirror(mirr);\r
+}\r
+\r
+static DECLFW(M225Write)\r
+{\r
+  uint32 bank = (A >> 14) & 1;\r
+  mirr = (A >> 13) & 1;\r
+  mode = (A >> 12) & 1;\r
+  chr = (A & 0x3f) | (bank << 6);\r
+  prg = ((A >> 6) & 0x3f) | (bank << 6);\r
+  Sync();\r
+}\r
+\r
+static DECLFW(M225LoWrite)\r
+{\r
+}\r
+\r
+static DECLFR(M225LoRead)\r
+{\r
+  return 0;\r
+}\r
+\r
+static void M225Power(void)\r
+{ \r
+  prg = 0;\r
+  mode = 0;\r
+  Sync();\r
+  SetReadHandler(0x5000,0x5fff,M225LoRead);\r
+  SetWriteHandler(0x5000,0x5fff,M225LoWrite);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0xFFFF,M225Write);\r
+}\r
+\r
+static void M225Reset(void)\r
+{\r
+  prg = 0;\r
+  mode = 0;\r
+  Sync();\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper225_Init(CartInfo *info)\r
+{\r
+  info->Reset=M225Reset;\r
+  info->Power=M225Power;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
index 8760d50..5e596fc 100644 (file)
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * VRC-2/VRC-4 Konami\r
+ * VRC-4 Pirate\r
  */\r
 \r
 #include "mapinc.h"\r
@@ -33,13 +36,13 @@ static uint32 WRAMSIZE;
 \r
 static SFORMAT StateRegs[]=\r
 {\r
-  {prgreg, 2, "PRGREGS"},\r
-  {chrreg, 8, "CHRREGS"},\r
-  {&regcmd, 1, "REGCMD"},\r
-  {&irqcmd, 1, "IRQCMD"},\r
+  {prgreg, 2, "PREG"},\r
+  {chrreg, 8, "CREG"},\r
+  {&regcmd, 1, "CMDR"},\r
+  {&irqcmd, 1, "CMDI"},\r
   {&mirr, 1, "MIRR"},\r
   {&big_bank, 1, "BIGB"},\r
-  {&IRQCount, 2, "IRCN"},\r
+  {&IRQCount, 2, "IRQC"},\r
   {&IRQLatch, 1, "IRQL"},\r
   {&IRQa, 1, "IRQA"},\r
   {0}\r
@@ -87,7 +90,7 @@ static DECLFW(M23Write)
     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
+    {\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
@@ -97,18 +100,18 @@ static DECLFW(M23Write)
   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
+      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
+      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
@@ -118,7 +121,7 @@ static DECLFW(M23Write)
                    break;\r
       case 0x9000:\r
       case 0x9001: if(V!=0xFF) mirr=V; Sync(); break;\r
-      case 0x9002: \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
@@ -129,7 +132,7 @@ static DECLFW(M23Write)
 \r
 static void M23Power(void)\r
 {\r
-  big_bank=0x20;  \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
@@ -138,11 +141,7 @@ static void M23Power(void)
   SetWriteHandler(0x8000,0xFFFF,M23Write);\r
 }\r
 \r
-static void M23Reset(void)\r
-{\r
-}\r
-\r
-void M23IRQHook(int a)\r
+void FP_FASTAPASS(1) M23IRQHook(int a)\r
 {\r
   #define LCYCS 341\r
   if(IRQa)\r
@@ -154,7 +153,7 @@ void M23IRQHook(int a)
       {\r
         acount-=LCYCS;\r
         IRQCount++;\r
-        if(IRQCount&0x100) \r
+        if(IRQCount&0x100)\r
         {\r
           X6502_IRQBegin(FCEU_IQEXT);\r
           IRQCount=IRQLatch;\r
index 4cae946..f6d927c 100644 (file)
@@ -15,7 +15,7 @@
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
  */\r
 \r
 #include "mapinc.h"\r
@@ -23,7 +23,7 @@
 static uint16 cmdreg;\r
 static SFORMAT StateRegs[]=\r
 {\r
-  {&cmdreg, 2, "CMDREG"},\r
+  {&cmdreg, 2, "CREG"},\r
   {0}\r
 };\r
 \r
index 6e3b569..908897a 100644 (file)
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * TODO: cram disable cases! (Shen Hua Jian Yun III cannot boot with CRAM enabled)\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 chrlo[8], chrhi[8], prg[2], mirr;\r
+static int32 IRQa, IRQCount, IRQLatch, IRQClock;\r
 static uint8 *WRAM=NULL;\r
 static uint32 WRAMSIZE;\r
 static uint8 *CHRRAM=NULL;\r
@@ -29,11 +31,10 @@ static uint32 CHRRAMSIZE;
 \r
 static SFORMAT StateRegs[]=\r
 {\r
-  {chrlo, 8, "CHRLO"},\r
-  {chrhi, 8, "CHRHI"},\r
+  {chrlo, 8, "CHRL"},\r
+  {chrhi, 8, "CHRH"},\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
@@ -52,17 +53,7 @@ static void Sync(void)
   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
+    if((chr==4)||(chr==5))\r
       setchr1r(0x10,i<<10,chr&1);\r
     else\r
       setchr1(i<<10,chr);\r
@@ -127,18 +118,18 @@ static void M253Close(void)
 \r
 static void M253IRQ(int cycles)\r
 {\r
-  if(IRQa&2) \r
+  if(IRQa&2)\r
   {\r
-    if((IRQClock+=cycles)>=0x72) \r
+    if((IRQClock+=cycles)>=0x71)\r
     {\r
-      IRQClock -= 0x72;\r
-      if(IRQCount==0xFF)  \r
+      IRQClock -= 0x71;\r
+      if(IRQCount==0xFF)\r
       {\r
         IRQCount = IRQLatch;\r
         IRQa = IRQa|((IRQa&1)<<1);\r
         X6502_IRQBegin(FCEU_IQEXT);\r
       }\r
-      else \r
+      else\r
         IRQCount++;\r
     }\r
   }\r
diff --git a/boards/34.c b/boards/34.c
new file mode 100644 (file)
index 0000000..a357506
--- /dev/null
@@ -0,0 +1,98 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2012 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * Many-in-one hacked mapper crap.\r
+ * \r
+ * Original BNROM is actually AxROM variations without mirroring control,\r
+ * and haven't SRAM on-board, so it must be removed from here\r
+ *\r
+ * Difficult banking is what NINA board doing, most hacks for 34 mapper are\r
+ * NINA hacks, so this is actually 34 mapper\r
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 regs[3];\r
+static uint8 *WRAM=NULL;\r
+static uint32 WRAMSIZE;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {regs, 3, "REGS"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setprg8r(0x10,0x6000,0);\r
+  setprg32(0x8000,regs[0]);\r
+  setchr4(0x0000,regs[1]);  \r
+  setchr4(0x1000,regs[2]);  \r
+}\r
+\r
+static DECLFW(M34Write)\r
+{\r
+  if(A>=0x8000)\r
+    regs[0] = V;\r
+  else\r
+    switch(A)\r
+    {\r
+      case 0x7ffd: regs[0] = V; break;\r
+      case 0x7ffe: regs[1] = V; break;\r
+      case 0x7fff: regs[2] = V; break;\r
+    }\r
+  Sync();\r
+}\r
+\r
+static void M34Power(void)\r
+{\r
+  regs[0] = 0;\r
+  Sync();\r
+  SetReadHandler(0x6000,0x7ffc,CartBR);\r
+  SetWriteHandler(0x6000,0x7ffc,CartBW);\r
+  SetReadHandler(0x8000,0xffff,CartBR);\r
+  SetWriteHandler(0x7ffd,0xffff,M34Write);\r
+}\r
+\r
+static void M34Close(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 Mapper34_Init(CartInfo *info)\r
+{\r
+  info->Power=M34Power;\r
+  info->Close=M34Close;\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 24572a4..0f71c27 100644 (file)
@@ -15,7 +15,7 @@
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
  */\r
 \r
 #include "mapinc.h"\r
@@ -70,7 +70,7 @@ static void UNL3DBlockReset(void)
   FCEU_printf("Count=%04x\n",Count);\r
 }\r
 \r
-static void UNL3DBlockIRQHook(int a)\r
+static void FP_FASTAPASS(1) UNL3DBlockIRQHook(int a)\r
 {\r
   if(IRQa)\r
   {\r
index 479a9bf..ab78499 100644 (file)
@@ -15,7 +15,7 @@
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
  */\r
 \r
 // actually cart ID is 811120-C, sorry ;) K-3094 - another ID\r
index ee12dec..94aa7b6 100644 (file)
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * FDS Conversion\r
+ *\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
+static uint32 IRQCount, IRQa;\r
 \r
 static SFORMAT StateRegs[]=\r
 {\r
@@ -36,7 +36,7 @@ static SFORMAT StateRegs[]=
 \r
 static void Sync(void)\r
 {\r
-  setprg4(0x5000,16);  \r
+  setprg4(0x5000,16);    // Only YS-612 advdnced version\r
   setprg8(0x6000,2);\r
   setprg8(0x8000,1);\r
   setprg8(0xa000,0);\r
@@ -47,11 +47,13 @@ static void Sync(void)
 \r
 static DECLFW(M43Write)\r
 {\r
-  int transo[8]={4,3,4,4,4,7,5,6};\r
+//  int transo[8]={4,3,4,4,4,7,5,6};\r
+  int transo[8]={4,3,5,3,6,3,7,3};  // According to hardware tests\r
   switch(A&0xf1ff)\r
   {\r
     case 0x4022: reg=transo[V&7]; Sync(); break;\r
-    case 0x8122: IRQa=V&1; IRQCount=0; break;\r
+    case 0x8122:                                                            // hacked version\r
+    case 0x4122: IRQa=V&1; X6502_IRQEnd(FCEU_IQEXT); IRQCount=0; break;     // original version\r
   }\r
 }\r
 \r
@@ -59,7 +61,6 @@ static void M43Power(void)
 {\r
   reg=0;\r
   Sync();\r
-//  SetReadHandler(0x5000,0x5fff,CartBR);\r
   SetReadHandler(0x5000,0xffff,CartBR);\r
   SetWriteHandler(0x4020,0xffff,M43Write);\r
 }\r
@@ -68,15 +69,15 @@ static void M43Reset(void)
 {\r
 }\r
 \r
-static void M43IRQHook(int a)\r
+static void FP_FASTAPASS(1) 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
 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
index ba5de0b..71cee43 100644 (file)
@@ -15,7 +15,7 @@
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
  *\r
  */\r
 \r
@@ -27,7 +27,7 @@ static uint8 hrd_flag;
 \r
 static SFORMAT StateRegs[]=\r
 {\r
-  {&hrd_flag, 1, "DIPSW"},\r
+  {&hrd_flag, 1, "DPSW"},\r
   {&prg_reg, 1, "PRG"},\r
   {&chr_reg, 1, "CHR"},\r
   {0}\r
index 43b4e0a..439c026 100644 (file)
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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
+ *\r
+ * Contra Fighter prot board\r
  */\r
 \r
 #include "mapinc.h"\r
index 6a9420c..08dfa8c 100644 (file)
@@ -15,7 +15,7 @@
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
  */\r
 \r
 #include "mapinc.h"\r
@@ -32,8 +32,8 @@ static SFORMAT StateRegs[]=
   {&nt2, 1, "NT2"},\r
   {&mirr, 1, "MIRR"},\r
   {&prg_reg, 1, "PRG"},\r
-  {&kogame, 1, "KOGAME"},\r
-  {&count, 4, "COUNT"},\r
+  {&kogame, 1, "KGME"},\r
+  {&count, 4, "CNT"},\r
   {chr_reg, 4, "CHR"},\r
   {0}\r
 };\r
@@ -96,6 +96,7 @@ static DECLFW(M68WriteLo)
     count = 0;\r
     setprg16r((PRGptr[1])?kogame:0,0x8000,prg_reg);\r
   }\r
+  CartBW(A,V);\r
 }\r
 \r
 static DECLFW(M68WriteCHR)\r
index 1b23023..ef42558 100644 (file)
@@ -15,7 +15,7 @@
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
  */\r
 \r
 #include "mapinc.h"\r
@@ -25,7 +25,7 @@ static uint8 invalid_data;
 static SFORMAT StateRegs[]=\r
 {\r
   {&invalid_data, 1, "INVD"},  \r
-  {&cmdreg, 2, "CMDREG"},\r
+  {&cmdreg, 2, "CREG"},\r
   {0}\r
 };\r
 \r
diff --git a/boards/82.c b/boards/82.c
new file mode 100644 (file)
index 0000000..7dfd276
--- /dev/null
@@ -0,0 +1,105 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2012 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * Taito X1-017 board, battery backed\r
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 regs[9], ctrl;\r
+static uint8 *WRAM=NULL;\r
+static uint32 WRAMSIZE;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {regs, 9, "REGS"},\r
+  {&ctrl, 1, "CTRL"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  uint32 swap = ((ctrl & 2) << 11);\r
+  setchr2(0x0000^swap,regs[0]>>1);  \r
+  setchr2(0x0800^swap,regs[1]>>1);  \r
+  setchr1(0x1000^swap,regs[2]);  \r
+  setchr1(0x1400^swap,regs[3]);  \r
+  setchr1(0x1800^swap,regs[4]);  \r
+  setchr1(0x1c00^swap,regs[5]);  \r
+  setprg8r(0x10,0x6000,0);\r
+  setprg8(0x8000,regs[6]);\r
+  setprg8(0xA000,regs[7]);\r
+  setprg8(0xC000,regs[8]);\r
+  setprg8(0xE000,~0);\r
+  setmirror(ctrl & 1);\r
+}\r
+\r
+static DECLFW(M82Write)\r
+{\r
+  if(A <= 0x7ef5)\r
+    regs[A & 7] = V;\r
+  else\r
+    switch(A)\r
+    {\r
+      case 0x7ef6: ctrl = V & 3; break;\r
+      case 0x7efa: regs[6] = V >> 2; break;\r
+      case 0x7efb: regs[7] = V >> 2; break;\r
+      case 0x7efc: regs[8] = V >> 2; break;\r
+    }\r
+  Sync();\r
+}\r
+\r
+static void M82Power(void)\r
+{\r
+  Sync();\r
+  SetReadHandler(0x6000,0xffff,CartBR);\r
+  SetWriteHandler(0x6000,0x7fff,CartBW);\r
+  SetWriteHandler(0x7ef0,0x7efc,M82Write);  // external WRAM might end at $73FF\r
+}\r
+\r
+static void M82Close(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 Mapper82_Init(CartInfo *info)\r
+{\r
+  info->Power=M82Power;\r
+  info->Power=M82Close;\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
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
index 0415338..3c401e6 100644 (file)
-/* 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
+/* FCE Ultra - NES/Famicom Emulator
+ *
+ * Copyright notice for this file:
+ *  Copyright (C) 2011 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
+ *
+ * Super Game (Sugar Softec) protected mapper
+ * Pocahontas 2 (Unl) [U][!], etc.
+ * TODO: 9in1 LION KING HANGS!
+ */
+
+#include "mapinc.h"
+#include "mmc3.h"
+
+static uint8 cmdin;
+
+static uint8 regperm[8][8] = 
+  {
+    {0, 1, 2, 3, 4, 5, 6, 7},
+    {0, 2, 6, 1, 7, 3, 4, 5},
+    {0, 5, 4, 1, 7, 2, 6, 3}, // unused
+    {0, 6, 3, 7, 5, 2, 4, 1},
+    {0, 2, 5, 3, 6, 1, 7, 4},
+    {0, 1, 2, 3, 4, 5, 6, 7}, // empty
+    {0, 1, 2, 3, 4, 5, 6, 7}, // empty
+    {0, 1, 2, 3, 4, 5, 6, 7}, // empty
+  };
+
+static uint8 adrperm[8][8] = 
+  {
+    {0, 1, 2, 3, 4, 5, 6, 7},
+    {3, 2, 0, 4, 1, 5, 6, 7},
+    {0, 1, 2, 3, 4, 5, 6, 7}, // unused
+    {5, 0, 1, 2, 3, 7, 6, 4},
+    {3, 1, 0, 5, 2, 4, 6, 7},
+    {0, 1, 2, 3, 4, 5, 6, 7}, // empty
+    {0, 1, 2, 3, 4, 5, 6, 7}, // empty
+    {0, 1, 2, 3, 4, 5, 6, 7}, // empty
+  };
+
+static void UNL8237CW(uint32 A, uint8 V)
+{
+  if(EXPREGS[0]&0x40)
+    setchr1(A,((EXPREGS[1]&0xc)<<6)|(V&0x7F)|((EXPREGS[1]&0x20)<<2));
+  else
+    setchr1(A,((EXPREGS[1]&0xc)<<6)|V);
+}
+
+static void UNL8237PW(uint32 A, uint8 V)
+{
+  if(EXPREGS[0]&0x40)
+  {
+    uint8 sbank = (EXPREGS[1]&0x10);
+    if(EXPREGS[0]&0x80)
+    {
+      uint8 bank = ((EXPREGS[1]&3)<<4)|(EXPREGS[0]&0x7)|(sbank>>1);
+      if(EXPREGS[0]&0x20)
+        setprg32(0x8000,bank>>1);
+      else
+      {
+        setprg16(0x8000,bank);
+        setprg16(0xC000,bank);
+      }
+    }
+    else
+      setprg8(A,((EXPREGS[1]&3)<<5)|(V&0x0F)|sbank);
+  }
+  else
+  {
+    if(EXPREGS[0]&0x80)
+    {
+      uint8 bank = ((EXPREGS[1]&3)<<4)|(EXPREGS[0]&0xF);
+      if(EXPREGS[0]&0x20)
+        setprg32(0x8000,bank>>1);
+      else
+      {
+        setprg16(0x8000,bank);
+        setprg16(0xC000,bank);
+      }
+    }
+    else
+      setprg8(A,((EXPREGS[1]&3)<<5)|(V&0x1F));
+  }
+}
+
+static void UNL8237ACW(uint32 A, uint8 V)
+{
+  if(EXPREGS[0]&0x40)
+    setchr1(A,((EXPREGS[1]&0xE)<<7)|(V&0x7F)|((EXPREGS[1]&0x20)<<2));
+  else
+    setchr1(A,((EXPREGS[1]&0xE)<<7)|V);
+}
+
+static void UNL8237APW(uint32 A, uint8 V)
+{
+  if(EXPREGS[0]&0x40)
+  {
+    uint8 sbank = (EXPREGS[1]&0x10);
+    if(EXPREGS[0]&0x80)
+    {
+      uint8 bank = ((EXPREGS[1]&3)<<4)|((EXPREGS[1]&8)<<3)|(EXPREGS[0]&0x7)|(sbank>>1);
+      if(EXPREGS[0]&0x20) {
+//        FCEU_printf("8000:%02X\n",bank>>1);
+        setprg32(0x8000,bank>>1);
+      }
+      else
+      {
+//        FCEU_printf("8000-C000:%02X\n",bank);
+        setprg16(0x8000,bank);
+        setprg16(0xC000,bank);
+      }
+    }
+    else {
+//      FCEU_printf("%04x:%02X\n",A,((EXPREGS[1]&3)<<5)|((EXPREGS[1]&8)<<4)|(V&0x0F)|sbank);
+      setprg8(A,((EXPREGS[1]&3)<<5)|((EXPREGS[1]&8)<<4)|(V&0x0F)|sbank);
+    }
+  }
+  else
+  {
+    if(EXPREGS[0]&0x80)
+    {
+      uint8 bank = ((EXPREGS[1]&3)<<4)|((EXPREGS[1]&8)<<3)|(EXPREGS[0]&0xF);
+      if(EXPREGS[0]&0x20) {
+//        FCEU_printf("8000:%02X\n",(bank>>1)&0x07);
+        setprg32(0x8000,bank>>1);
+      }
+      else
+      {
+//        FCEU_printf("8000-C000:%02X\n",bank&0x0F);
+        setprg16(0x8000,bank);
+        setprg16(0xC000,bank);
+      }
+    }
+    else {
+//      FCEU_printf("%04X:%02X\n",A,(((EXPREGS[1]&3)<<5)|((EXPREGS[1]&8)<<4)|(V&0x1F))&0x1F);
+      setprg8(A,((EXPREGS[1]&3)<<5)|((EXPREGS[1]&8)<<4)|(V&0x1F));
+    }
+  }
+}
+static DECLFW(UNL8237Write)
+{
+  uint8 dat = V;
+  uint8 adr = adrperm[EXPREGS[2]][((A>>12)&6)|(A&1)];
+  uint16 addr = (adr & 1)|((adr & 6)<<12)|0x8000;
+  if(adr < 4)
+  {
+    if(!adr)
+      dat = (dat & 0xC0)|(regperm[EXPREGS[2]][dat & 7]);
+    MMC3_CMDWrite(addr,dat);
+  }
+  else 
+    MMC3_IRQWrite(addr,dat);
+}
+
+static DECLFW(UNL8237ExWrite)
+{
+  switch(A)
+  {
+    case 0x5000: EXPREGS[0]=V; FixMMC3PRG(MMC3_cmd); break;
+    case 0x5001: EXPREGS[1]=V; FixMMC3PRG(MMC3_cmd); FixMMC3CHR(MMC3_cmd); break;
+    case 0x5007: EXPREGS[2]=V; break;
+  }
+}
+
+static void UNL8237Power(void)
+{
+  EXPREGS[0]=EXPREGS[2]=0;
+  EXPREGS[1]=3;
+  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, "CMDI");
+}
+
+void UNL8237A_Init(CartInfo *info)
+{
+  GenMMC3_Init(info, 256, 256, 0, 0);
+  cwrap=UNL8237ACW;
+  pwrap=UNL8237APW;
+  info->Power=UNL8237Power;
+  AddExState(EXPREGS, 3, 0, "EXPR");
+  AddExState(&cmdin, 1, 0, "CMDI");
+}
index 8b6ce60..bdfb56d 100644 (file)
@@ -15,7 +15,7 @@
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
  */\r
 \r
 // M-022 MMC3 based 830118C T-106 4M + 4M\r
@@ -23,8 +23,6 @@
 #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
index 88d45ce..03fbf5b 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include "mapinc.h"
index caccc09..074f560 100644 (file)
@@ -16,7 +16,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include "mapinc.h"
@@ -52,15 +52,15 @@ static uint8 tekker;
 static SFORMAT Tek_StateRegs[]={
   {&IRQMode, 1, "IRQM"},
   {&IRQPre, 1, "IRQP"},
-  {&IRQPreSize, 1, "IRQS"},
+  {&IRQPreSize, 1, "IRQR"},
   {&IRQCount, 1, "IRQC"},
   {&IRQXOR, 1, "IRQX"},
-  {&IRQa, 1, "IRQa"},
+  {&IRQa, 1, "IRQA"},
   {mul, 2, "MUL"},
   {&regie, 1, "REGI"},
   {tkcom, 4, "TKCO"},
   {prgb, 4, "PRGB"},
-  {chr, 2, "CHRA"},
+  {chr, 2, "CLTC"},
   {chrlow, 4, "CHRL"},
   {chrhigh, 8, "CHRH"},
   {&names[0], 2|FCEUSTATE_RLSB, "NMS0"},
@@ -104,27 +104,30 @@ static void mira(void)
   }
 }
 
-static void tekprom(void)
+static void tekprom(void) // TODO: verify for single, small multi and large multi
 {
   uint32 bankmode=((tkcom[3]&6)<<5);
   switch(tkcom[0]&7)
   {
     case 00: if(tkcom[0]&0x80)
                setprg8(0x6000,(((prgb[3]<<2)+3)&0x3F)|bankmode);
-             setprg32(0x8000,0x0F|((tkcom[3]&6)<<3));
+             setprg32(0x8000,(prgb[3]&7)|((tkcom[3]&7)<<3));
              break;
     case 01: if(tkcom[0]&0x80)
                setprg8(0x6000,(((prgb[3]<<1)+1)&0x3F)|bankmode);
-             setprg16(0x8000,(prgb[1]&0x1F)|((tkcom[3]&6)<<4));
-             setprg16(0xC000,0x1F|((tkcom[3]&6)<<4));
+             setprg16(0x8000,(prgb[1]&0x0F)|((tkcom[3]&7)<<4));
+             setprg16(0xC000,0x0F|((tkcom[3]&7)<<4));
              break;
     case 03: // bit reversion
-    case 02: if(tkcom[0]&0x80)
-               setprg8(0x6000,(prgb[3]&0x3F)|bankmode);
-             setprg8(0x8000,(prgb[0]&0x3F)|bankmode);
-             setprg8(0xa000,(prgb[1]&0x3F)|bankmode);
-             setprg8(0xc000,(prgb[2]&0x3F)|bankmode);
-             setprg8(0xe000,0x3F|bankmode);
+    case 02: 
+             if(tkcom[0]&0x80)
+               setprg8(0x6000,(prgb[3]&0x1F)|((tkcom[3]&7)<<5)); // 45in1 multy has different bits, seems board was hacked to support big data banks
+             setprg8(0x8000,(prgb[0]&0x1F)|((tkcom[3]&7)<<5));
+             setprg8(0xa000,(prgb[1]&0x1F)|((tkcom[3]&7)<<5));
+             setprg8(0xc000,(prgb[2]&0x1F)|((tkcom[3]&7)<<5));
+             setprg8(0xe000,0x1F|((tkcom[3]&7)<<5));
+//             setprg8(0xe000,(prgb[3]&0x0F)|((tkcom[3]&6)<<3));
+//             setprg32(0x8000,((prgb[0]&0x0F)>>2)|((tkcom[3]&6)<<3));
              break;
     case 04: if(tkcom[0]&0x80)
                setprg8(0x6000,(((prgb[3]<<2)+3)&0x3F)|bankmode);
@@ -253,19 +256,19 @@ 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");
+               /*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;
@@ -366,7 +369,7 @@ static void ClockCounter(void)
   }
 }
 
-void CPUWrap(int a)
+void FP_FASTAPASS(1) CPUWrap(int a)
 {
   int x;
   if((IRQMode&3)==0) for(x=0;x<a;x++) ClockCounter();
@@ -379,7 +382,7 @@ static void SLWrap(void)
 }
 
 static uint32 lastread;
-static void M90PPU(uint32 A)
+static void FP_FASTAPASS(1) M90PPU(uint32 A)
 {
   if((IRQMode&3)==2)
   {
@@ -446,7 +449,6 @@ static void M90Power(void)
   SetWriteHandler(0xD000,0xD5ff,M90ModeWrite);
   SetWriteHandler(0xE000,0xFfff,M90DummyWrite);
 
-
   SetReadHandler(0x5000,0x5fff,M90TekRead);
   SetReadHandler(0x6000,0xffff,CartBR);
 
diff --git a/boards/91.c b/boards/91.c
new file mode 100644 (file)
index 0000000..0fed9df
--- /dev/null
@@ -0,0 +1,95 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2012 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 cregs[4], pregs[2];\r
+static uint8 IRQCount, IRQa;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {cregs, 4, "CREG"},\r
+  {pregs, 2, "PREG"},\r
+  {&IRQa, 1, "IRQA"},\r
+  {&IRQCount, 1, "IRQC"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setprg8(0x8000,pregs[0]);\r
+  setprg8(0xa000,pregs[1]);\r
+  setprg8(0xc000,~1);\r
+  setprg8(0xe000,~0);\r
+  setchr2(0x0000,cregs[0]);\r
+  setchr2(0x0800,cregs[1]);\r
+  setchr2(0x1000,cregs[2]);\r
+  setchr2(0x1800,cregs[3]);\r
+}\r
+\r
+static DECLFW(M91Write0)\r
+{\r
+  cregs[A & 3] = V;\r
+  Sync();\r
+}\r
+\r
+static DECLFW(M91Write1)\r
+{\r
+  switch (A & 3)\r
+  {\r
+    case 0:\r
+    case 1: pregs[A & 1] = V; Sync(); break;\r
+    case 2: IRQa = IRQCount = 0; X6502_IRQEnd(FCEU_IQEXT); break;\r
+    case 3: IRQa = 1; X6502_IRQEnd(FCEU_IQEXT); break;\r
+  }\r
+}\r
+\r
+static void M91Power(void)\r
+{\r
+  Sync();\r
+  SetWriteHandler(0x6000,0x6fff,M91Write0);\r
+  SetWriteHandler(0x7000,0x7fff,M91Write1);\r
+  SetReadHandler(0x8000,0xffff,CartBR);\r
+}\r
+\r
+static void M91IRQHook(void)\r
+{\r
+  if(IRQCount<8 && IRQa)\r
+  {\r
+    IRQCount++;\r
+    if(IRQCount>=8)\r
+    {\r
+      X6502_IRQBegin(FCEU_IQEXT);   \r
+    } \r
+  }\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper91_Init(CartInfo *info)\r
+{\r
+  info->Power=M91Power;\r
+  GameHBIRQHook=M91IRQHook;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
index 0a5d9dd..7b69435 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include "mapinc.h"
-#include "../ines.h"
 
 static uint8 lastA;
 static uint8 DRegs[8];
@@ -79,7 +78,7 @@ static DECLFW(Mapper95_write)
   }
 }
 
-static void dragonbust_ppu(uint32 A)
+static void FP_FASTAPASS(1) dragonbust_ppu(uint32 A)
 {
   static int last=-1;
   static uint8 z;
diff --git a/boards/96.c b/boards/96.c
new file mode 100644 (file)
index 0000000..aa9d8a7
--- /dev/null
@@ -0,0 +1,84 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 1998 BERO\r
+ *  Copyright (C) 2002 Xodnizel\r
+ *  Copyright (C) 2012 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * Oeka-kids board\r
+ *\r
+ * I might want to add some code to the mapper 96 PPU hook function\r
+ * to not change CHR banks if the attribute table is being accessed,\r
+ * if I make emulation a little more accurate in the future.\r
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg, ppulatch;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&reg, 1, "REG"},\r
+  {&ppulatch, 1, "PPUL"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setmirror(MI_0);\r
+  setprg32(0x8000,reg & 3);\r
+  setchr4(0x0000,(reg & 4) | ppulatch);\r
+  setchr4(0x1000,(reg & 4) | 3);\r
+}\r
+\r
+static DECLFW(M96Write)\r
+{\r
+  reg = V;\r
+  Sync();\r
+}\r
+\r
+static void FP_FASTAPASS(1) M96Hook(uint32 A)\r
+{\r
+  if((A & 0x3000) == 0x2000)\r
+  {\r
+    ppulatch = (A>>8) & 3;\r
+    Sync();\r
+  }\r
+}\r
+\r
+static void M96Power(void)\r
+{\r
+  reg = ppulatch = 0;\r
+  Sync();\r
+  SetReadHandler(0x8000,0xffff,CartBR);\r
+  SetWriteHandler(0x8000,0xffff,M96Write);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper96_Init(CartInfo *info)\r
+{\r
+  info->Power=M96Power;\r
+  PPU_hook=M96Hook;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
+\r
diff --git a/boards/99.c b/boards/99.c
new file mode 100644 (file)
index 0000000..826af3e
--- /dev/null
@@ -0,0 +1,67 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2012 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * VS Super Mario Bros has a problem, FCEUX doesn't!\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 latch;\r
+static writefunc old4016;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&latch, 1, "LATC"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setchr8((latch >> 2) & 1);\r
+  setprg32(0x8000,0);\r
+  setprg8(0x8000,latch & 4);        /* Special for VS Gumshoe */\r
+}\r
+\r
+static DECLFW(M99Write)\r
+{\r
+  latch = V;\r
+  Sync();\r
+  old4016(A,V);\r
+}\r
+\r
+static void M99Power(void)\r
+{\r
+  latch = 0;\r
+  Sync();\r
+  old4016=GetWriteHandler(0x4016);\r
+  SetWriteHandler(0x4016,0x4016,M99Write);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper99_Init(CartInfo *info)\r
+{\r
+  info->Power=M99Power;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
similarity index 62%
rename from boards/179.c
rename to boards/KS7012.c
index 91a530f..b764ff8 100644 (file)
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * FDS Conversion\r
+ *\r
  */\r
 \r
 #include "mapinc.h"\r
 \r
-static uint8 reg[2];\r
-\r
+static uint8 reg;\r
 static uint8 *WRAM=NULL;\r
 static uint32 WRAMSIZE;\r
 \r
 static SFORMAT StateRegs[]=\r
 {\r
-  {reg, 2, "REG"},\r
+  {&reg, 1, "REGS"},\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
+  setprg32(0x8000,reg&1);\r
+  setchr8(0);\r
+}\r
+\r
+static DECLFW(UNLKS7012Write)\r
+{\r
+//  FCEU_printf("bs %04x %02x\n",A,V);\r
+  switch(A)\r
+  {\r
+    case 0xE0A0: reg=0; Sync(); break;\r
+    case 0xEE36: reg=1; Sync(); break;\r
+  }\r
 }\r
 \r
-static DECLFW(M179Write)\r
+static void UNLKS7012Power(void)\r
 {\r
-  if(A==0xa000) reg[0]=V;\r
+  reg = ~0;\r
   Sync();\r
+  SetReadHandler(0x6000,0x7FFF,CartBR);\r
+  SetWriteHandler(0x6000,0x7FFF,CartBW);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0xFFFF,UNLKS7012Write);\r
 }\r
 \r
-static DECLFW(M179WriteLo)\r
+static void UNLKS7012Reset(void)\r
 {\r
-  if(A==0x5ff1) reg[1]=V;\r
+  reg = ~0;\r
   Sync();\r
 }\r
 \r
-static void M179Power(void)\r
+static void StateRestore(int version)\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
+  Sync();\r
 }\r
 \r
-static void M179Close(void)\r
+static void UNLKS7012Close(void)\r
 {\r
   if(WRAM)\r
     FCEU_gfree(WRAM);\r
   WRAM=NULL;\r
 }\r
 \r
-static void StateRestore(int version)\r
+void UNLKS7012_Init(CartInfo *info)\r
 {\r
-  Sync();\r
-}\r
-\r
-void Mapper179_Init(CartInfo *info)\r
-{\r
-  info->Power=M179Power;\r
-  info->Close=M179Close;\r
-  GameStateRestore=StateRestore;\r
+  info->Power=UNLKS7012Power;\r
+  info->Reset=UNLKS7012Reset;\r
+  info->Close=UNLKS7012Close;\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
+  GameStateRestore=StateRestore;\r
   AddExState(&StateRegs, ~0, 0, 0);\r
 }\r
diff --git a/boards/KS7013.c b/boards/KS7013.c
new file mode 100644 (file)
index 0000000..8476003
--- /dev/null
@@ -0,0 +1,84 @@
+/* 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * Just another pirate cart with pirate mapper, instead of original MMC1\r
+ * Kaiser Highway Star\r
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg, mirr;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&reg, 1, "REGS"},\r
+  {&mirr, 1, "MIRR"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setprg16(0x8000,reg);\r
+  setprg16(0xc000,~0);\r
+  setmirror(mirr);\r
+  setchr8(0);\r
+}\r
+\r
+static DECLFW(UNLKS7013BLoWrite)\r
+{\r
+  reg = V;\r
+  Sync();\r
+}\r
+\r
+static DECLFW(UNLKS7013BHiWrite)\r
+{\r
+  mirr = (V & 1) ^ 1;\r
+  Sync();\r
+}\r
+\r
+static void UNLKS7013BPower(void)\r
+{\r
+  reg = 0;\r
+  mirr = 0;\r
+  Sync();\r
+  SetWriteHandler(0x6000,0x7FFF,UNLKS7013BLoWrite);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0xFFFF,UNLKS7013BHiWrite);\r
+}\r
+\r
+static void UNLKS7013BReset(void)\r
+{\r
+  reg = 0;\r
+  Sync();\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void UNLKS7013B_Init(CartInfo *info)\r
+{\r
+  info->Power=UNLKS7013BPower;\r
+  info->Reset=UNLKS7013BReset;\r
+\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
diff --git a/boards/KS7017.c b/boards/KS7017.c
new file mode 100644 (file)
index 0000000..9402f99
--- /dev/null
@@ -0,0 +1,134 @@
+/* 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * FDS Conversion\r
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg, mirr;\r
+static int32 IRQa, IRQCount, IRQLatch;\r
+static uint8 *WRAM=NULL;\r
+static uint32 WRAMSIZE;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&mirr, 1, "MIRR"},\r
+  {&reg, 1, "REGS"},\r
+  {&IRQa, 4, "IRQA"},\r
+  {&IRQCount, 4, "IRQC"},\r
+  {&IRQLatch, 4, "IRQL"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setprg16(0x8000,reg);\r
+  setprg16(0xC000,2);\r
+  setmirror(mirr);\r
+}\r
+\r
+static DECLFW(UNLKS7017Write)\r
+{\r
+//  FCEU_printf("bs %04x %02x\n",A,V);\r
+    if((A & 0xFF00) == 0x4A00)\r
+    {\r
+      reg = ((A >> 2) & 3)|((A >> 4) & 4);\r
+    }\r
+    else if ((A & 0xFF00) == 0x5100)\r
+    {\r
+      Sync();\r
+    }\r
+    else if (A == 0x4020)\r
+    {\r
+      X6502_IRQEnd(FCEU_IQEXT);\r
+      IRQCount&=0xFF00;\r
+      IRQCount|=V;\r
+    }\r
+    else if (A == 0x4021)\r
+    {\r
+      X6502_IRQEnd(FCEU_IQEXT);\r
+      IRQCount&=0xFF;\r
+      IRQCount|=V<<8;\r
+      IRQa = 1;\r
+    }\r
+    else if (A == 0x4025)\r
+    {\r
+      mirr = ((V & 8) >> 3) ^ 1;\r
+    }\r
+}\r
+\r
+static DECLFR(FDSRead4030)\r
+{\r
+  X6502_IRQEnd(FCEU_IQEXT);\r
+  return X.IRQlow&FCEU_IQEXT?1:0;\r
+}\r
+\r
+static void FP_FASTAPASS(1) UNL7017IRQ(int a)\r
+{\r
+ if(IRQa)\r
+ {\r
+  IRQCount-=a;\r
+  if(IRQCount<=0)\r
+  {\r
+    IRQa=0;\r
+    X6502_IRQBegin(FCEU_IQEXT);\r
+  }\r
+ }\r
+}\r
+\r
+static void UNLKS7017Power(void)\r
+{\r
+  Sync();\r
+  setchr8(0);\r
+  setprg8r(0x10,0x6000,0);\r
+  SetReadHandler(0x6000,0x7FFF,CartBR);\r
+  SetWriteHandler(0x6000,0x7FFF,CartBW);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetReadHandler(0x4030,0x4030,FDSRead4030);\r
+  SetWriteHandler(0x4020,0x5FFF,UNLKS7017Write);\r
+}\r
+\r
+static void UNLKS7017Close(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 UNLKS7017_Init(CartInfo *info)\r
+{\r
+  info->Power=UNLKS7017Power;\r
+  info->Close=UNLKS7017Close;\r
+  MapIRQHook=UNL7017IRQ;\r
+\r
+  WRAMSIZE=8192;\r
+  WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);\r
+  SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);\r
+  AddExState(WRAM, WRAMSIZE, 0, "WRAM");\r
+\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
diff --git a/boards/KS7030.c b/boards/KS7030.c
new file mode 100644 (file)
index 0000000..58abf0e
--- /dev/null
@@ -0,0 +1,151 @@
+/* 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * FDS Conversion\r
+ *\r
+ * Logical bank layot 32 K BANK 0, 64K BANK 1, 32K ~0 hardwired, 8K is missing\r
+ * need redump from MASKROM!\r
+ * probably need refix mapper after hard dump\r
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg0, reg1;\r
+static uint8 *WRAM=NULL;\r
+static uint32 WRAMSIZE;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&reg0, 1, "REG0"},\r
+  {&reg1, 1, "REG1"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setchr8(0);\r
+  setprg32(0x8000,~0);\r
+  setprg4(0xb800,reg0);\r
+  setprg4(0xc800,8+reg1);\r
+}\r
+\r
+// 6000 - 6BFF - RAM\r
+// 6C00 - 6FFF - BANK 1K REG1\r
+// 7000 - 7FFF - BANK 4K REG0\r
+\r
+static DECLFW(UNLKS7030RamWrite0)\r
+{\r
+  if((A >= 0x6000) && A <= 0x6BFF) {\r
+    WRAM[A-0x6000]=V;\r
+  } else if((A >= 0x6C00) && A <= 0x6FFF) {\r
+    CartBW(0xC800 + (A - 0x6C00), V);\r
+  } else if((A >= 0x7000) && A <= 0x7FFF) {\r
+    CartBW(0xB800 + (A - 0x7000), V);\r
+  }\r
+}\r
+\r
+static DECLFR(UNLKS7030RamRead0)\r
+{\r
+  if((A >= 0x6000) && A <= 0x6BFF) {\r
+    return WRAM[A-0x6000];\r
+  } else if((A >= 0x6C00) && A <= 0x6FFF) {\r
+    return CartBR(0xC800 + (A - 0x6C00));\r
+  } else if((A >= 0x7000) && A <= 0x7FFF) {\r
+    return CartBR(0xB800 + (A - 0x7000));\r
+  }\r
+  return 0;\r
+}\r
+\r
+// B800 - BFFF - RAM\r
+// C000 - CBFF - BANK 3K\r
+// CC00 - D7FF - RAM\r
+\r
+static DECLFW(UNLKS7030RamWrite1)\r
+{\r
+  if((A >= 0xB800) && A <= 0xBFFF) {\r
+    WRAM[0x0C00+(A-0xB800)]=V;\r
+  } else if((A >= 0xC000) && A <= 0xCBFF) {\r
+    CartBW(0xCC00 + (A - 0xC000), V);\r
+  } else if((A >= 0xCC00) && A <= 0xD7FF) {\r
+    WRAM[0x1400+(A-0xCC00)]=V;\r
+  }\r
+}\r
+\r
+static DECLFR(UNLKS7030RamRead1)\r
+{\r
+  if((A >= 0xB800) && A <= 0xBFFF) {\r
+    return WRAM[0x0C00+(A-0xB800)];\r
+  } else if((A >= 0xC000) && A <= 0xCBFF) {\r
+    return CartBR(0xCC00 + (A - 0xC000));\r
+  } else if((A >= 0xCC00) && A <= 0xD7FF) {\r
+    return WRAM[0x1400+(A-0xCC00)];\r
+  }\r
+  return 0;\r
+}\r
+\r
+static DECLFW(UNLKS7030Write0)\r
+{\r
+  reg0=A&7;\r
+  Sync();\r
+}\r
+\r
+static DECLFW(UNLKS7030Write1)\r
+{\r
+  reg1=A&15;\r
+  Sync();\r
+}\r
+\r
+static void UNLKS7030Power(void)\r
+{\r
+  reg0=reg1=~0;\r
+  Sync();\r
+  SetReadHandler(0x6000,0x7FFF,UNLKS7030RamRead0);\r
+  SetWriteHandler(0x6000,0x7FFF,UNLKS7030RamWrite0);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0x8FFF,UNLKS7030Write0);\r
+  SetWriteHandler(0x9000,0x9FFF,UNLKS7030Write1);\r
+  SetReadHandler(0xB800,0xD7FF,UNLKS7030RamRead1);\r
+  SetWriteHandler(0xB800,0xD7FF,UNLKS7030RamWrite1);\r
+}\r
+\r
+static void UNLKS7030Close(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 UNLKS7030_Init(CartInfo *info)\r
+{\r
+  info->Power=UNLKS7030Power;\r
+  info->Close=UNLKS7030Close;\r
+  GameStateRestore=StateRestore;\r
+\r
+  WRAMSIZE=8192;\r
+  WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);\r
+  AddExState(WRAM, WRAMSIZE, 0, "WRAM");\r
+\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
diff --git a/boards/KS7031.c b/boards/KS7031.c
new file mode 100644 (file)
index 0000000..e2b8769
--- /dev/null
@@ -0,0 +1,85 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2012 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * FDS Conversion\r
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg[4];\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {reg, 4, "REGS"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setprg2(0x6000,reg[0]);\r
+  setprg2(0x6800,reg[1]);\r
+  setprg2(0x7000,reg[2]);\r
+  setprg2(0x7800,reg[3]);\r
+\r
+  setprg2(0x8000,15);\r
+  setprg2(0x8800,14);\r
+  setprg2(0x9000,13);\r
+  setprg2(0x9800,12);\r
+  setprg2(0xa000,11);\r
+  setprg2(0xa800,10);\r
+  setprg2(0xb000,9);\r
+  setprg2(0xb800,8);\r
+\r
+  setprg2(0xc000,7);\r
+  setprg2(0xc800,6);\r
+  setprg2(0xd000,5);\r
+  setprg2(0xd800,4);\r
+  setprg2(0xe000,3);\r
+  setprg2(0xe800,2);\r
+  setprg2(0xf000,1);\r
+  setprg2(0xf800,0);\r
+\r
+  setchr8(0);\r
+}\r
+\r
+static DECLFW(UNLKS7031Write)\r
+{\r
+  reg[(A >> 11) & 3] = V;\r
+  Sync();\r
+}\r
+\r
+static void UNLKS7031Power(void)\r
+{\r
+  Sync();\r
+  SetReadHandler(0x6000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0xffff,UNLKS7031Write);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void UNLKS7031_Init(CartInfo *info)\r
+{\r
+  info->Power=UNLKS7031Power;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
similarity index 78%
rename from boards/ks7032.c
rename to boards/KS7032.c
index fcb0eb5..c93fc15 100644 (file)
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * FDS Conversion\r
+ *\r
  */\r
 \r
 #include "mapinc.h"\r
 \r
-static uint8 reg[8], cmd, IRQa;\r
+static uint8 reg[8], cmd, IRQa = 0, isirqused = 0;\r
 static int32 IRQCount;\r
 \r
 static SFORMAT StateRegs[]=\r
@@ -45,20 +48,20 @@ static void Sync(void)
 static DECLFW(UNLKS7032Write)\r
 {\r
 //  FCEU_printf("bs %04x %02x\n",A,V);\r
-  switch(A)\r
+  switch(A&0xF000)\r
   {\r
 //    case 0x8FFF: reg[4]=V; Sync(); break;\r
-    case 0x8000: X6502_IRQEnd(FCEU_IQEXT); IRQCount=(IRQCount&0x000F)|(V&0x0F); break;\r
-    case 0x9000: X6502_IRQEnd(FCEU_IQEXT); IRQCount=(IRQCount&0x00F0)|((V&0x0F)<<4); break;\r
-    case 0xA000: X6502_IRQEnd(FCEU_IQEXT); IRQCount=(IRQCount&0x0F00)|((V&0x0F)<<8); break;\r
-    case 0xB000: X6502_IRQEnd(FCEU_IQEXT); IRQCount=(IRQCount&0xF000)|(V<<12); break;\r
-    case 0xC000: X6502_IRQEnd(FCEU_IQEXT); IRQa=1; break;\r
+    case 0x8000: X6502_IRQEnd(FCEU_IQEXT); IRQCount=(IRQCount&0x000F)|(V&0x0F); isirqused = 1; break;\r
+    case 0x9000: X6502_IRQEnd(FCEU_IQEXT); IRQCount=(IRQCount&0x00F0)|((V&0x0F)<<4); isirqused = 1; break;\r
+    case 0xA000: X6502_IRQEnd(FCEU_IQEXT); IRQCount=(IRQCount&0x0F00)|((V&0x0F)<<8); isirqused = 1; break;\r
+    case 0xB000: X6502_IRQEnd(FCEU_IQEXT); IRQCount=(IRQCount&0xF000)|(V<<12); isirqused = 1; break;\r
+    case 0xC000: if(isirqused) { X6502_IRQEnd(FCEU_IQEXT); IRQa=1; } break;\r
     case 0xE000: cmd=V&7; break;\r
     case 0xF000: reg[cmd]=V; Sync(); break;\r
   }\r
 }\r
 \r
-static void UNLSMB2JIRQHook(int a)\r
+static void FP_FASTAPASS(1) UNLSMB2JIRQHook(int a)\r
 {\r
   if(IRQa)\r
   {\r
diff --git a/boards/KS7037.c b/boards/KS7037.c
new file mode 100644 (file)
index 0000000..d980a6f
--- /dev/null
@@ -0,0 +1,135 @@
+/* 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * FDS Conversion\r
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg[8], cmd;\r
+static uint8 *WRAM=NULL;\r
+static uint32 WRAMSIZE;\r
+\r
+static void(*WSync)(void);\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&cmd, 1, "CMD"},\r
+  {reg, 8, "REGS"},\r
+  {0}\r
+};\r
+\r
+static void SyncKS7037(void)\r
+{\r
+  setprg4r(0x10,0x6000,0);\r
+  setprg4(0x7000,15);\r
+  setprg8(0x8000,reg[6]);\r
+  setprg4(0xA000,~3);\r
+  setprg4r(0x10,0xB000,1);\r
+  setprg8(0xC000,reg[7]);\r
+  setprg8(0xE000,~0);\r
+  setchr8(0);\r
+  setmirrorw(reg[2]&1,reg[4]&1,reg[3]&1,reg[5]&1);\r
+}\r
+\r
+static void SyncLH10(void)\r
+{\r
+  setprg8(0x6000,~1);\r
+  setprg8(0x8000,reg[6]);\r
+  setprg8(0xA000,reg[7]);\r
+  setprg8r(0x10,0xC000,0);\r
+  setprg8(0xE000,~0);\r
+  setchr8(0);\r
+  setmirror(0);\r
+}\r
+\r
+static DECLFW(UNLKS7037Write)\r
+{\r
+  switch(A & 0xE001)\r
+  {\r
+    case 0x8000: cmd = V & 7; break;\r
+    case 0x8001: reg[cmd] = V; WSync(); break;\r
+  }\r
+}\r
+\r
+static void UNLKS7037Power(void)\r
+{\r
+  reg[0]=reg[1]=reg[2]=reg[3]=reg[4]=reg[5]=reg[6]=reg[7]=0;\r
+  WSync();\r
+  SetReadHandler(0x6000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x6000,0x7FFF,CartBW);\r
+  SetWriteHandler(0x8000,0x9FFF,UNLKS7037Write);\r
+  SetWriteHandler(0xA000,0xBFFF,CartBW);\r
+  SetWriteHandler(0xC000,0xFFFF,UNLKS7037Write);\r
+}\r
+\r
+static void LH10Power(void)\r
+{\r
+  reg[0]=reg[1]=reg[2]=reg[3]=reg[4]=reg[5]=reg[6]=reg[7]=0;\r
+  WSync();\r
+  SetReadHandler(0x6000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0xBFFF,UNLKS7037Write);\r
+  SetWriteHandler(0xC000,0xDFFF,CartBW);\r
+  SetWriteHandler(0xE000,0xFFFF,UNLKS7037Write);\r
+}\r
+\r
+static void Close(void)\r
+{\r
+  if(WRAM)\r
+    FCEU_gfree(WRAM);\r
+  WRAM=NULL;\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  WSync();\r
+}\r
+\r
+void UNLKS7037_Init(CartInfo *info)\r
+{\r
+  info->Power=UNLKS7037Power;\r
+  info->Close=Close;\r
+  \r
+  WSync = SyncKS7037;\r
+\r
+  WRAMSIZE=8192;\r
+  WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);\r
+  SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);\r
+  AddExState(WRAM, WRAMSIZE, 0, "WRAM");\r
+\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
+\r
+void LH10_Init(CartInfo *info)\r
+{\r
+  info->Power=LH10Power;\r
+  info->Close=Close;\r
+  \r
+  WSync = SyncLH10;\r
+\r
+  WRAMSIZE=8192;\r
+  WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);\r
+  SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);\r
+  AddExState(WRAM, WRAMSIZE, 0, "WRAM");\r
+\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
diff --git a/boards/KS7057.c b/boards/KS7057.c
new file mode 100644 (file)
index 0000000..8dd3caa
--- /dev/null
@@ -0,0 +1,97 @@
+/* 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * FDS Conversion\r
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg[8], mirror;\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {reg, 8, "PRG"},\r
+  {&mirror, 1, "MIRR"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setprg2(0x6000,reg[4]);\r
+  setprg2(0x6800,reg[5]);\r
+  setprg2(0x7000,reg[6]);\r
+  setprg2(0x7800,reg[7]);\r
+  setprg2(0x8000,reg[0]);\r
+  setprg2(0x8800,reg[1]);\r
+  setprg2(0x9000,reg[2]);\r
+  setprg2(0x9800,reg[3]);\r
+  setprg8(0xA000,0xd);\r
+  setprg16(0xC000,7);\r
+  setchr8(0);\r
+  setmirror(mirror);\r
+}\r
+\r
+static DECLFW(UNLKS7057Write)\r
+{\r
+  switch(A&0xF003) {\r
+   case 0x8000:\r
+   case 0x8001:\r
+   case 0x8002:\r
+   case 0x8003:\r
+   case 0x9000: \r
+   case 0x9001: \r
+   case 0x9002: \r
+   case 0x9003: mirror = V & 1; Sync(); break;\r
+   case 0xB000: reg[0] = (reg[0] & 0xF0) | (V & 0x0F); Sync(); break;\r
+   case 0xB001: reg[0] = (reg[0] & 0x0F) | (V << 4); Sync(); break;\r
+   case 0xB002: reg[1] = (reg[1] & 0xF0) | (V & 0x0F); Sync(); break;\r
+   case 0xB003: reg[1] = (reg[1] & 0x0F) | (V << 4); Sync(); break;\r
+   case 0xC000: reg[2] = (reg[2] & 0xF0) | (V & 0x0F); Sync(); break;\r
+   case 0xC001: reg[2] = (reg[2] & 0x0F) | (V << 4); Sync(); break;\r
+   case 0xC002: reg[3] = (reg[3] & 0xF0) | (V & 0x0F); Sync(); break;\r
+   case 0xC003: reg[3] = (reg[3] & 0x0F) | (V << 4); Sync(); break;\r
+   case 0xD000: reg[4] = (reg[4] & 0xF0) | (V & 0x0F); Sync(); break;\r
+   case 0xD001: reg[4] = (reg[4] & 0x0F) | (V << 4); Sync(); break;\r
+   case 0xD002: reg[5] = (reg[5] & 0xF0) | (V & 0x0F); Sync(); break;\r
+   case 0xD003: reg[5] = (reg[5] & 0x0F) | (V << 4); Sync(); break;\r
+   case 0xE000: reg[6] = (reg[6] & 0xF0) | (V & 0x0F); Sync(); break;\r
+   case 0xE001: reg[6] = (reg[6] & 0x0F) | (V << 4); Sync(); break;\r
+   case 0xE002: reg[7] = (reg[7] & 0xF0) | (V & 0x0F); Sync(); break;\r
+   case 0xE003: reg[7] = (reg[7] & 0x0F) | (V << 4); Sync(); break;\r
+  }\r
+}\r
+\r
+static void UNLKS7057Power(void)\r
+{\r
+  Sync();\r
+  SetReadHandler(0x6000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0xFFFF,UNLKS7057Write);\r
+}\r
+\r
+static void UNLKS7057Reset(void)\r
+{\r
+  Sync();\r
+}\r
+\r
+void UNLKS7057_Init(CartInfo *info)\r
+{\r
+  info->Power=UNLKS7057Power;\r
+  info->Reset=UNLKS7057Reset;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
index b14ee56..33f1c5f 100644 (file)
@@ -10,10 +10,8 @@ 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
@@ -37,7 +35,6 @@ 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
@@ -61,12 +58,10 @@ 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
@@ -84,5 +79,44 @@ B_C += boards/t-262.c
 B_C += boards/tengen.c
 B_C += boards/tf-1201.c
 
+B_C += boards/12in1.c
+B_C += boards/151.c
+B_C += boards/156.c
+B_C += boards/168.c
+B_C += boards/17.c
+B_C += boards/170.c
+B_C += boards/18.c
+B_C += boards/193.c
+B_C += boards/225.c
+B_C += boards/34.c
+B_C += boards/82.c
+B_C += boards/91.c
+B_C += boards/96.c
+B_C += boards/99.c
+B_C += boards/KS7012.c
+B_C += boards/KS7013.c
+B_C += boards/KS7017.c
+B_C += boards/KS7030.c
+B_C += boards/KS7031.c
+B_C += boards/KS7032.c
+B_C += boards/KS7037.c
+B_C += boards/KS7057.c
+B_C += boards/SA-9602B.c
+B_C += boards/__serial.c
+B_C += boards/ac-08.c
+B_C += boards/bb.c
+B_C += boards/cityfighter.c
+B_C += boards/copyfami_emu.c
+B_C += boards/copyfami_hwi.c
+B_C += boards/dance2000.c
+B_C += boards/famicombox.c
+B_C += boards/le05.c
+B_C += boards/lh32.c
+B_C += boards/lh53.c
+B_C += boards/pec-586.c
+B_C += boards/transformer.c
+B_C += boards/vrc7.c
+B_C += boards/yoko.c
+
 MUOBJS += $(patsubst %.c,%.o,$(B_C))
 
diff --git a/boards/SA-9602B.c b/boards/SA-9602B.c
new file mode 100644 (file)
index 0000000..c39fdac
--- /dev/null
@@ -0,0 +1,67 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2012 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+#include "mmc3.h"\r
+\r
+static void SA9602BPW(uint32 A, uint8 V)\r
+{\r
+  setprg8r(EXPREGS[1],A,V&0x3F);\r
+  if(MMC3_cmd&0x40)\r
+    setprg8r(0,0x8000,~(1));\r
+  else\r
+    setprg8r(0,0xc000,~(1));\r
+  setprg8r(0,0xe000,~(0));\r
+}\r
+\r
+static DECLFW(SA9602BWrite)\r
+{\r
+  switch(A & 0xe001)\r
+  {\r
+    case 0x8000: EXPREGS[0] = V; break;\r
+    case 0x8001:\r
+      if((EXPREGS[0] & 7) < 6)\r
+      {\r
+        EXPREGS[1] = V >> 6;\r
+        FixMMC3PRG(MMC3_cmd);\r
+      }\r
+      break;\r
+  }\r
+  MMC3_CMDWrite(A, V);\r
+}\r
+\r
+static void SA9602BPower(void)\r
+{\r
+  EXPREGS[0]=EXPREGS[1]=0;\r
+  GenMMC3Power();\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0xBFFF,SA9602BWrite);\r
+}\r
+\r
+void SA9602B_Init(CartInfo *info)\r
+{\r
+  GenMMC3_Init(info, 512, 0, 0, 0);\r
+  pwrap=SA9602BPW;\r
+  mmc3opts|=2;\r
+  info->SaveGame[0]=UNIFchrrama;\r
+  info->SaveGameLen[0]=32 * 1024;\r
+  info->Power=SA9602BPower;\r
+  AddExState(EXPREGS, 2, 0, "EXPR");\r
+}\r
index f56736d..eaa40f9 100644 (file)
@@ -1,7 +1,7 @@
 /* FCE Ultra - NES/Famicom Emulator\r
  *\r
  * Copyright notice for this file:\r
- *  Copyright (C) 2009 CaH4e3\r
+ *  Copyright (C) 2012 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
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
  */\r
 \r
 #include "mapinc.h"\r
 \r
 static uint8 reg[8];\r
+static uint8 IRQa;\r
+static int16 IRQCount, IRQLatch;\r
 /*\r
 static uint8 *WRAM=NULL;\r
 static uint32 WRAMSIZE;\r
@@ -31,6 +33,9 @@ static uint32 CHRRAMSIZE;
 static SFORMAT StateRegs[]=\r
 {\r
   {reg, 8, "REGS"},\r
+  {&IRQa, 1, "IRQA"},\r
+  {&IRQCount, 2, "IRQC"},\r
+  {&IRQLatch, 2, "IRQL"},\r
   {0}\r
 };\r
 \r
@@ -65,7 +70,7 @@ static void MNNNClose(void)
 }\r
 */\r
 \r
-static void MNNNIRQHook(void)\r
+static void MNNNIRQHook()\r
 {\r
   X6502_IRQBegin(FCEU_IQEXT);\r
 }\r
diff --git a/boards/__serial.c b/boards/__serial.c
new file mode 100644 (file)
index 0000000..3b48240
--- /dev/null
@@ -0,0 +1,124 @@
+\r
+#include "__serial.h"\r
+\r
+HANDLE SerialPort = NULL;  // Handle of SerialPort itself.\r
+\r
+BOOL SerialOpen(int port, int baud)\r
+{\r
+  HANDLE Comport;\r
+  DCB myDCB;\r
+  COMMTIMEOUTS CTout;\r
+  char str[100];\r
+\r
+  if (port > 9)\r
+    sprintf(str, "\\\\.\\COM%d", port);\r
+  else\r
+    sprintf(str, "COM%d", port);\r
+\r
+  // Open the serial port\r
+  if ((Comport = CreateFile(str, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE)\r
+    return FALSE;\r
+\r
+  // Configure Serial port (Setup Comm)\r
+\r
+  // Buffer sizes\r
+  if (!SetupComm(Comport, 128, 128))\r
+    return FALSE;\r
+\r
+  // Setup DCB using current values\r
+  if (!GetCommState(Comport, &myDCB))\r
+    return FALSE;\r
+\r
+  myDCB.fInX = FALSE;     // Turn off xon/xoff handler\r
+  myDCB.fOutX = FALSE;\r
+  myDCB.fOutxDsrFlow = FALSE;\r
+  myDCB.fOutxCtsFlow = FALSE;    // no hardware flow control.\r
+  myDCB.BaudRate = baud;\r
+  myDCB.DCBlength = sizeof(DCB);\r
+  myDCB.fBinary = 1;\r
+  myDCB.fParity = 0;\r
+  myDCB.fDtrControl = DTR_CONTROL_DISABLE;\r
+  myDCB.fDsrSensitivity = 0;\r
+  myDCB.fTXContinueOnXoff = 1;\r
+  myDCB.fNull = 0;\r
+  myDCB.fRtsControl = RTS_CONTROL_DISABLE;\r
+  myDCB.fDummy2 = 0;\r
+  myDCB.wReserved = 0;\r
+  myDCB.Parity = NOPARITY;\r
+  myDCB.StopBits = ONESTOPBIT;\r
+  myDCB.wReserved1 = 0;\r
+  myDCB.ByteSize = 8;\r
+\r
+  if (!SetCommState(Comport, &myDCB))\r
+       return FALSE;\r
+\r
+  // Set timeouts\r
+  CTout.ReadIntervalTimeout = 0xffffffff;\r
+  CTout.ReadTotalTimeoutMultiplier = 0;\r
+  CTout.ReadTotalTimeoutConstant = 0;\r
+  CTout.WriteTotalTimeoutMultiplier = 0;\r
+  CTout.WriteTotalTimeoutConstant = 5000;         // don't hang if CTS is locked, for example\r
+\r
+  SetCommTimeouts(Comport, &CTout);\r
+  EscapeCommFunction(Comport, SETDTR);\r
+  PurgeComm(Comport, PURGE_TXCLEAR | PURGE_RXCLEAR);\r
+\r
+  SerialPort = Comport;\r
+\r
+  return TRUE;\r
+}\r
+\r
+void SerialClose(void)\r
+{\r
+  if (SerialPort == NULL) return;\r
+\r
+  PurgeComm(SerialPort, PURGE_TXCLEAR | PURGE_RXCLEAR);\r
+  CloseHandle(SerialPort);\r
+\r
+  SerialPort = NULL;\r
+}\r
+\r
+BOOL SerialSendChar(int c)\r
+{\r
+  DWORD cr;\r
+  if(WriteFile(SerialPort, &c, 1, (LPDWORD)&cr, NULL) && cr)\r
+    return TRUE;\r
+  else\r
+    return FALSE;\r
+}\r
+\r
+int SerialIsOpen(void)\r
+{\r
+  return (SerialPort != NULL);\r
+}\r
+\r
+int SerialGetChar(void)\r
+{\r
+  uint8 ch;\r
+  DWORD cr;\r
+  if (SerialPort != NULL) {\r
+    if (ReadFile(SerialPort, &ch, 1, (LPDWORD)&cr, NULL) && cr)\r
+      return (int)ch;\r
+  }\r
+  return EOF;\r
+}\r
+\r
+void SendCmd(uint8 *cmd, int size)\r
+{\r
+   int i;\r
+   for(i=0; i<size; i++) {\r
+     SerialSendChar(cmd[i]);\r
+   }\r
+}\r
+\r
+int ReadResp(uint8 *resp, int size)\r
+{\r
+   int i = 0, sum = 0, data;\r
+   while(i < size) {\r
+          while ((data = SerialGetChar()) == EOF) {}\r
+       resp[i] = data & 0xff;\r
+       sum += (data & 0xff);\r
+       i++;\r
+   }\r
+   return sum;\r
+}\r
diff --git a/boards/__serial.h b/boards/__serial.h
new file mode 100644 (file)
index 0000000..05ebb3f
--- /dev/null
@@ -0,0 +1,21 @@
+#ifndef __SERIAL_H\r
+#define __SERIAL_H\r
+\r
+#include <stdio.h>\r
+#include <windows.h>\r
+#include "../types.h"\r
+\r
+void SendCmd(uint8 *cmd, int size);\r
+int ReadResp(uint8 *resp, int size);\r
+\r
+#define SEND(cmd) SendCmd((uint8 *)&cmd[0], sizeof(cmd))\r
+#define GET(buf, size) ReadResp((uint8 *)&buf, size)\r
+#define SENDGET(cmd, buf, size) SEND(cmd); GET(buf, size)\r
+\r
+BOOL SerialOpen(int port, int baud);\r
+void SerialClose(void);\r
+BOOL SerialSendChar(int c);\r
+int  SerialIsOpen(void);\r
+int  SerialGetChar(void);\r
+\r
+#endif\r
diff --git a/boards/a9711.c b/boards/a9711.c
deleted file mode 100644 (file)
index 3fb5460..0000000
+++ /dev/null
@@ -1,78 +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
-#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
index 3522336..1030cad 100644 (file)
@@ -1,4 +1,3 @@
-\r
 /* FCE Ultra - NES/Famicom Emulator\r
  *\r
  * Copyright notice for this file:\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
  */\r
 \r
 #include "mapinc.h"\r
@@ -183,4 +77,4 @@ void UNLA9746_Init(CartInfo *info)
   info->Power=UNLA9746Power;\r
   AddExState(EXPREGS, 6, 0, "EXPR");\r
 }\r
-/**/\r
+\r
diff --git a/boards/ac-08.c b/boards/ac-08.c
new file mode 100644 (file)
index 0000000..906bbb1
--- /dev/null
@@ -0,0 +1,77 @@
+/* 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * FDS Conversion\r
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg, 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
+  setprg8(0x6000, reg);\r
+  setprg32r(1, 0x8000, 0);\r
+  setchr8(0);\r
+  setmirror(mirr);\r
+}\r
+\r
+static DECLFW(AC08Mirr)\r
+{\r
+  mirr = ((V&8)>>3)^1;\r
+  Sync();\r
+}\r
+\r
+static DECLFW(AC08Write)\r
+{\r
+  if(A == 0x8001)              // Green Berret bank switching is only 100x xxxx xxxx xxx1 mask\r
+   reg = (V >> 1) & 0xf;\r
+  else\r
+   reg = V & 0xf;              // Sad But True, 2-in-1 mapper, Green Berret need value shifted left one byte, Castlevania doesn't\r
+  Sync();\r
+}\r
+\r
+static void AC08Power(void)\r
+{\r
+  reg = 0;\r
+  Sync();\r
+  SetReadHandler(0x6000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x4025,0x4025,AC08Mirr);\r
+  SetWriteHandler(0x8000,0xFFFF,AC08Write);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void AC08_Init(CartInfo *info)\r
+{\r
+  info->Power=AC08Power;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
index 4b70d6e..afd0919 100644 (file)
@@ -15,7 +15,7 @@
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
  */\r
 \r
 #include "mapinc.h"\r
@@ -27,7 +27,7 @@ static readfunc defread;
 \r
 static DECLFW(LatchWrite)\r
 {\r
-  FCEU_printf("%04x:%02x\n",A,V);\r
+//  FCEU_printf("%04x:%02x\n",A,V);\r
   latche=A;\r
   WSync();\r
 }\r
@@ -119,6 +119,41 @@ void BMCD1038_Init(CartInfo *info)
 }\r
 \r
 \r
+//------------------ UNL43272 ---------------------------\r
+// mapper much complex, including 16K bankswitching \r
+static void UNL43272Sync(void)\r
+{\r
+  if((latche&0x81) == 0x81)\r
+  {\r
+    setprg32(0x8000,(latche&0x38)>>3);\r
+  }\r
+  else\r
+    FCEU_printf("unrecognized command %04!\n",latche);\r
+  setchr8(0);\r
+  setmirror(0);\r
+}\r
+\r
+static DECLFR(UNL43272Read)\r
+{\r
+  if(latche&0x400)\r
+    return CartBR(A & 0xFE);\r
+  else\r
+    return CartBR(A);\r
+}\r
+\r
+static void UNL43272Reset(void)\r
+{\r
+  latche = 0;\r
+  UNL43272Sync();\r
+}\r
+\r
+void UNL43272_Init(CartInfo *info)\r
+{ \r
+  Latch_Init(info, UNL43272Sync, UNL43272Read, 0x81, 0x8000, 0xFFFF);\r
+  info->Reset=UNL43272Reset;\r
+  AddExState(&dipswitch, 1, 0, "DIPSW");\r
+}\r
+\r
 //------------------ Map 058 ---------------------------\r
 \r
 static void BMCGK192Sync(void)\r
@@ -139,6 +174,39 @@ void BMCGK192_Init(CartInfo *info)
   Latch_Init(info, BMCGK192Sync, 0, 0, 0x8000, 0xFFFF);\r
 }\r
 \r
+//------------------ Map 092 ---------------------------\r
+// Another two-in-one mapper, two Jaleco carts uses similar\r
+// hardware, but with different wiring.\r
+// Original code provided by LULU\r
+// Additionally, PCB contains DSP extra sound chip, used for voice samples (unemulated)\r
+\r
+static void M92Sync(void)\r
+{\r
+  uint8 reg = latche & 0xF0;\r
+  setprg16(0x8000,0);\r
+  if(latche>=0x9000)\r
+  {\r
+    switch (reg)\r
+    {\r
+      case 0xD0: setprg16(0xc000, latche & 15); break;\r
+      case 0xE0: setchr8(latche & 15); break;\r
+    }\r
+  }\r
+  else\r
+  {\r
+    switch (reg)\r
+    {\r
+      case 0xB0: setprg16(0xc000, latche & 15); break;\r
+      case 0x70: setchr8(latche & 15); break;\r
+    }\r
+  }\r
+}\r
+\r
+void Mapper92_Init(CartInfo *info)\r
+{\r
+  Latch_Init(info, M92Sync, 0, 0x80B0, 0x8000, 0xFFFF);\r
+}\r
+\r
 //------------------ Map 200 ---------------------------\r
 \r
 static void M200Sync(void)\r
@@ -170,3 +238,49 @@ void BMC190in1_Init(CartInfo *info)
   Latch_Init(info, BMC190in1Sync, 0, 0, 0x8000, 0xFFFF);\r
 }\r
 \r
+//-------------- BMC810544-C-A1 ------------------------\r
+\r
+static void BMC810544CA1Sync(void)\r
+{\r
+  uint32 bank = latche>>7;\r
+  if(latche&0x40)\r
+    setprg32(0x8000,bank);\r
+  else\r
+  {\r
+    setprg16(0x8000,(bank<<1)|((latche>>5)&1));\r
+    setprg16(0xC000,(bank<<1)|((latche>>5)&1));\r
+  }\r
+  setchr8(latche&0x0f);\r
+  setmirror(((latche>>4)&1)^1);\r
+}\r
+\r
+void BMC810544CA1_Init(CartInfo *info)\r
+{ \r
+  Latch_Init(info, BMC810544CA1Sync, 0, 0, 0x8000, 0xFFFF);\r
+}\r
+\r
+//-------------- BMCNTD-03 ------------------------\r
+\r
+static void BMCNTD03Sync(void)\r
+{\r
+  // 1PPP Pmcc spxx xccc\r
+  // 1000 0000 0000 0000 v\r
+  // 1001 1100 0000 0100 h\r
+  // 1011 1010 1100 0100\r
+  uint32 prg = ((latche>>10)&0x1e);\r
+  uint32 chr = ((latche&0x0300)>>5)|(latche&7);\r
+  if(latche&0x80)\r
+  {\r
+    setprg16(0x8000,prg|((latche>>6)&1));\r
+    setprg16(0xC000,prg|((latche>>6)&1));\r
+  }\r
+  else\r
+    setprg32(0x8000,prg>>1);\r
+  setchr8(chr);\r
+  setmirror(((latche>>10)&1)^1);\r
+}\r
+\r
+void BMCNTD03_Init(CartInfo *info)\r
+{ \r
+  Latch_Init(info, BMCNTD03Sync, 0, 0, 0x8000, 0xFFFF);\r
+}\r
index 66f1498..823381a 100644 (file)
@@ -15,7 +15,7 @@
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
  *\r
  * Super Bros. Pocker Mali (VRC4 mapper)\r
  */\r
@@ -54,11 +54,11 @@ static void UNLAX5705IRQ(void)
 \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
+  int i;\r
   for(i=0; i<8; i++)\r
      setchr1(i<<10,chr_reg[i]);     \r
   setmirror(mirr^1);   \r
index 8468aad..8928bfb 100644 (file)
@@ -2,7 +2,6 @@
  *\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
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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
@@ -45,33 +39,37 @@ static SFORMAT StateRegs[]=
   {0}\r
 };\r
 \r
-static void BandaiIRQHook(int a)\r
+static void FP_FASTAPASS(1) BandaiIRQHook(int a)\r
 {\r
   if(IRQa)\r
   {\r
-    IRQCount -= a;\r
+    IRQCount-=a;\r
     if(IRQCount<0)\r
     {\r
       X6502_IRQBegin(FCEU_IQEXT);\r
-      IRQa = 0;\r
-      IRQCount = -1;\r
+      IRQa=0;\r
+      IRQCount=0xFFFF;\r
     }\r
   }\r
 }\r
 \r
 static void BandaiSync(void)\r
 {\r
+  if(!UNIFchrrama)\r
+  {\r
+    int i;\r
+    for(i=0; i<8; i++) setchr1(i<<10,reg[i]);\r
+  }\r
+  else\r
+    setchr8(0);\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
@@ -96,41 +94,17 @@ static DECLFW(BandaiWrite)
     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 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
@@ -147,12 +121,31 @@ void Mapper16_Init(CartInfo *info)
   AddExState(&StateRegs, ~0, 0, 0);\r
 }\r
 \r
-void Mapper159_Init(CartInfo *info)\r
+// Famicom jump 2:\r
+// 0-7: Lower bit of data selects which 256KB PRG block is in use.\r
+// This seems to be a hack on the developers' part, so I'll make emulation\r
+// of it a hack(I think the current PRG block would depend on whatever the\r
+// lowest bit of the CHR bank switching register that corresponds to the\r
+// last CHR address read).\r
+\r
+static void M153Power(void)\r
 {\r
-  Mapper16_Init(info);\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
 void Mapper153_Init(CartInfo *info)\r
 {\r
   is153=1;\r
@@ -174,3 +167,190 @@ void Mapper153_Init(CartInfo *info)
   GameStateRestore=StateRestore;\r
   AddExState(&StateRegs, ~0, 0, 0);\r
 }\r
+\r
+// Datach Barcode Battler\r
+\r
+static uint8 BarcodeData[256];\r
+static int BarcodeReadPos;\r
+static int BarcodeCycleCount;\r
+static uint32 BarcodeOut;\r
+\r
+int FCEUI_DatachSet(const uint8 *rcode)\r
+{\r
+  int prefix_parity_type[10][6] = {\r
+    {0,0,0,0,0,0}, {0,0,1,0,1,1}, {0,0,1,1,0,1}, {0,0,1,1,1,0},\r
+    {0,1,0,0,1,1}, {0,1,1,0,0,1}, {0,1,1,1,0,0}, {0,1,0,1,0,1},\r
+    {0,1,0,1,1,0}, {0,1,1,0,1,0}\r
+  };\r
+  int data_left_odd[10][7] = {\r
+    {0,0,0,1,1,0,1}, {0,0,1,1,0,0,1}, {0,0,1,0,0,1,1}, {0,1,1,1,1,0,1},\r
+    {0,1,0,0,0,1,1}, {0,1,1,0,0,0,1}, {0,1,0,1,1,1,1}, {0,1,1,1,0,1,1},\r
+    {0,1,1,0,1,1,1}, {0,0,0,1,0,1,1}\r
+  };\r
+  int  data_left_even[10][7] = {\r
+    {0,1,0,0,1,1,1}, {0,1,1,0,0,1,1}, {0,0,1,1,0,1,1}, {0,1,0,0,0,0,1},\r
+    {0,0,1,1,1,0,1}, {0,1,1,1,0,0,1}, {0,0,0,0,1,0,1}, {0,0,1,0,0,0,1},\r
+    {0,0,0,1,0,0,1}, {0,0,1,0,1,1,1}\r
+  };\r
+  int  data_right[10][7] = {\r
+    {1,1,1,0,0,1,0}, {1,1,0,0,1,1,0}, {1,1,0,1,1,0,0}, {1,0,0,0,0,1,0},\r
+    {1,0,1,1,1,0,0}, {1,0,0,1,1,1,0}, {1,0,1,0,0,0,0}, {1,0,0,0,1,0,0},\r
+    {1,0,0,1,0,0,0}, {1,1,1,0,1,0,0}\r
+  };\r
+  uint8 code[13+1];\r
+  uint32 tmp_p=0;\r
+  int i, j;\r
+  int len;\r
+\r
+  for(i=len=0;i<13;i++)\r
+  {\r
+    if(!rcode[i]) break;\r
+    if((code[i]=rcode[i]-'0') > 9)\r
+      return(0);\r
+    len++;\r
+  }\r
+  if(len!=13 && len!=12 && len!=8 && len!=7) return(0);\r
+\r
+  #define BS(x) BarcodeData[tmp_p]=x;tmp_p++\r
+\r
+  for(j=0;j<32;j++)\r
+  {\r
+    BS(0x00);\r
+  }\r
+\r
+  /* Left guard bars */\r
+  BS(1);    BS(0); BS(1);\r
+\r
+  if(len==13 || len==12)\r
+  {\r
+    uint32 csum;\r
+\r
+    for(i=0;i<6;i++)\r
+      if(prefix_parity_type[code[0]][i])\r
+      {\r
+        for(j=0;j<7;j++)\r
+        {\r
+          BS(data_left_even[code[i+1]][j]);\r
+        }\r
+      }\r
+      else\r
+        for(j=0;j<7;j++)\r
+        {\r
+          BS(data_left_odd[code[i+1]][j]);\r
+        }\r
+\r
+    /* Center guard bars */\r
+    BS(0); BS(1); BS(0); BS(1); BS(0);\r
+\r
+    for(i=7;i<12;i++)\r
+      for(j=0;j<7;j++)\r
+      {\r
+        BS(data_right[code[i]][j]);\r
+      }\r
+    csum=0;\r
+    for(i=0;i<12;i++) csum+=code[i]*((i&1)?3:1);\r
+      csum=(10-(csum%10))%10;\r
+    for(j=0;j<7;j++)\r
+    {\r
+      BS(data_right[csum][j]);\r
+    }\r
+\r
+  }\r
+  else if(len==8 || len==7)\r
+  {\r
+    uint32 csum=0;\r
+\r
+    for(i=0;i<7;i++) csum+=(i&1)?code[i]:(code[i]*3);\r
+\r
+    csum=(10-(csum%10))%10;\r
+\r
+    for(i=0;i<4;i++)\r
+      for(j=0;j<7;j++)\r
+      {\r
+        BS(data_left_odd[code[i]][j]);\r
+      }\r
+\r
+\r
+    /* Center guard bars */\r
+    BS(0); BS(1); BS(0); BS(1); BS(0);\r
+\r
+    for(i=4;i<7;i++)\r
+      for(j=0;j<7;j++)\r
+      {\r
+        BS(data_right[code[i]][j]);\r
+      }\r
+\r
+    for(j=0;j<7;j++)\r
+      { BS(data_right[csum][j]);}\r
+\r
+  }\r
+\r
+  /* Right guard bars */\r
+  BS(1); BS(0); BS(1);\r
+\r
+  for(j=0;j<32;j++)\r
+  {\r
+    BS(0x00);\r
+  }\r
+\r
+  BS(0xFF);\r
+\r
+  #undef BS\r
+\r
+  BarcodeReadPos=0;\r
+  BarcodeOut=0x8;\r
+  BarcodeCycleCount=0;\r
+  return(1);\r
+}\r
+\r
+static void FP_FASTAPASS(1) BarcodeIRQHook(int a)\r
+{\r
+ BandaiIRQHook(a);\r
+\r
+ BarcodeCycleCount+=a;\r
+\r
+ if(BarcodeCycleCount >= 1000)\r
+ {\r
+  BarcodeCycleCount -= 1000;\r
+  if(BarcodeData[BarcodeReadPos]==0xFF)\r
+  {\r
+   BarcodeOut=0;\r
+  }\r
+  else\r
+  {\r
+   BarcodeOut=(BarcodeData[BarcodeReadPos]^1)<<3;\r
+   BarcodeReadPos++;\r
+  }\r
+ }\r
+}\r
+\r
+static DECLFR(BarcodeRead)\r
+{\r
+  return BarcodeOut;\r
+}\r
+\r
+static void M157Power(void)\r
+{\r
+  BarcodeData[0]=0xFF;\r
+  BarcodeReadPos=0;\r
+  BarcodeOut=0;\r
+  BarcodeCycleCount=0;\r
+\r
+  BandaiSync();\r
+\r
+  SetWriteHandler(0x6000,0xFFFF,BandaiWrite);\r
+  SetReadHandler(0x6000,0x7FFF,BarcodeRead);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+}\r
+\r
+void Mapper157_Init(CartInfo *info)\r
+{\r
+  is153=0;\r
+  info->Power=M157Power;\r
+  MapIRQHook=BarcodeIRQHook;\r
+\r
+  FCEUGameInfo->cspecial = SIS_DATACH;\r
+\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
diff --git a/boards/bb.c b/boards/bb.c
new file mode 100644 (file)
index 0000000..4cc0974
--- /dev/null
@@ -0,0 +1,73 @@
+/* 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * FDS Conversion\r
+ *\r
+ * Bubble Bobble CHR-ROM version\r
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg, chr;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&reg, 1, "REG"},\r
+  {&chr, 1, "CHR"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setprg8(0x6000,reg&3);\r
+  setprg32(0x8000,~0);\r
+  setchr8(chr&3);\r
+}\r
+\r
+static DECLFW(UNLBBWrite)\r
+{\r
+  if((A & 0x9000) == 0x8000)\r
+    reg=chr=V;\r
+  else\r
+    chr=V&1;      // hacky hacky, ProWres simplified FDS conversion 2-in-1 mapper\r
+  Sync();\r
+}\r
+\r
+static void UNLBBPower(void)\r
+{\r
+  chr = 0;\r
+  reg = ~0;\r
+  Sync();\r
+  SetReadHandler(0x6000,0x7FFF,CartBR);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0xFFFF,UNLBBWrite);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void UNLBB_Init(CartInfo *info)\r
+{\r
+  info->Power=UNLBBPower;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
index 89aa4fb..b7d9d7e 100644 (file)
@@ -15,9 +15,9 @@
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
  *\r
- * BMC 42-in-1 reset switch\r
+ * BMC 42-in-1 "reset switch" type\r
  */\r
 \r
 #include "mapinc.h"\r
index bcbdfc1..6c1f209 100644 (file)
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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
+ * BMC 42-in-1 "reset switch" + "select switch"\r
  *\r
  */\r
 \r
 #include "mapinc.h"\r
 \r
-static uint8 latche[2];\r
+static uint8 isresetbased = 0;\r
+static uint8 latche[2], reset;\r
 static SFORMAT StateRegs[]=\r
 {\r
-  {&latche, sizeof(latche), "LATCHE"},\r
+  {&reset, 1, "RST"},\r
+  {latche, 2, "LATC"},\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
+  uint8 bank;\r
+  if(isresetbased)\r
+    bank = (latche[0]&0x1f)|(reset<<5)|((latche[1]&1)<<6);\r
+  else\r
+    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
@@ -56,7 +59,7 @@ static DECLFW(M226Write)
 \r
 static void M226Power(void)\r
 {\r
-  latche[0] = latche[1] = 0;\r
+  latche[0] = latche[1] = reset = 0;\r
   Sync();\r
   SetWriteHandler(0x8000,0xFFFF,M226Write);\r
   SetReadHandler(0x8000,0xFFFF,CartBR);\r
@@ -69,8 +72,23 @@ static void StateRestore(int version)
 \r
 void Mapper226_Init(CartInfo *info)\r
 {\r
+  isresetbased = 0;\r
   info->Power=M226Power;\r
   AddExState(&StateRegs, ~0, 0, 0);\r
   GameStateRestore=StateRestore;\r
 }\r
 \r
+static void BMC42in1Reset(void)\r
+{\r
+  reset ^= 1;\r
+  Sync();\r
+}\r
+\r
+void BMC42in1r_Init(CartInfo *info)\r
+{\r
+  isresetbased = 1;\r
+  info->Power=M226Power;\r
+  info->Reset=BMC42in1Reset;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+  GameStateRestore=StateRestore;\r
+}\r
index 4f90c9f..a8dd291 100644 (file)
@@ -15,9 +15,9 @@
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
  *\r
- * BMC 42-in-1 reset switch\r
+ * BMC 42-in-1 "reset switch" type\r
  */\r
 \r
 #include "mapinc.h"\r
index 75baaa5..7970c08 100644 (file)
@@ -15,7 +15,7 @@
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
  */\r
 \r
 #include "mapinc.h"\r
@@ -29,7 +29,7 @@ static uint8 mirroring;
 static SFORMAT StateRegs[]=\r
 {\r
   {&large_bank, 1, "LB"},\r
-  {&hw_switch, 1, "DIPSW"},\r
+  {&hw_switch, 1, "DPSW"},\r
   {&prg_bank, 1, "PRG"},\r
   {&chr_bank, 1, "CHR"},\r
   {&bank_mode, 1, "BM"},\r
index a618f90..20fc10d 100644 (file)
@@ -15,7 +15,7 @@
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
  */\r
 \r
 #include "mapinc.h"\r
@@ -33,6 +33,12 @@ static SFORMAT StateRegs[]=
 \r
 /*\r
 \r
+cmd[0] = response on/off\r
+         0x00 - on\r
+         0x80 - off\r
+cmd[1] = cmd\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
@@ -81,7 +87,7 @@ byte_8CC6:           .BYTE   0,$78,  0,  0,$12
 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
+                                 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10 };\r
 \r
 static void Sync(void)\r
 {\r
index ad7a82a..85c74df 100644 (file)
@@ -15,7 +15,7 @@
  *\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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
  */\r
 \r
 #include "mapinc.h"\r
@@ -26,8 +26,8 @@ static uint8 dip_switch;
 \r
 static SFORMAT StateRegs[]=\r
 {\r
-  {reg_prg, 4, "PREGS"},\r
-  {reg_chr, 4, "CREGS"},\r
+  {reg_prg, 4, "PREG"},\r
+  {reg_chr, 4, "CREG"},\r
   {0}\r
 };\r
 \r
diff --git a/boards/cityfighter.c b/boards/cityfighter.c
new file mode 100644 (file)
index 0000000..11eb859
--- /dev/null
@@ -0,0 +1,134 @@
+/* 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * City Fighter IV sith Sound VRC4 hacked\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 IRQCount;\r
+static uint8 IRQPre;\r
+static uint8 IRQa;\r
+static uint8 prg_reg, prg_mode, mirr;\r
+static uint8 chr_reg[8];\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&IRQCount, 1, "IRQC"},\r
+  {&IRQPre, 1, "IRQP"},\r
+  {&IRQa, 1, "IRQA"},\r
+  {&prg_reg, 1, "PREG"},\r
+  {&prg_mode, 1, "PMOD"},\r
+  {&mirr, 1, "MIRR"},\r
+  {chr_reg, 8, "CREG"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setprg32(0x8000,prg_reg>>2);\r
+  if(!prg_mode)\r
+    setprg8(0xC000,prg_reg);\r
+  int i;\r
+  for(i=0; i<8; i++)\r
+     setchr1(i<<10,chr_reg[i]);     \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(UNLCITYFIGHTWrite)\r
+{\r
+  switch(A&0xF00C)\r
+  {\r
+    case 0x9000: prg_reg=V&0xC; mirr=V&3; break;\r
+    case 0x9004:\r
+    case 0x9008:\r
+    case 0x900C: prg_reg=V&0xC; break;\r
+    case 0xC000:\r
+    case 0xC004:\r
+    case 0xC008:\r
+    case 0xC00C: prg_mode=V&1; break;\r
+    case 0xD000: chr_reg[0]=(chr_reg[0]&0xF0)|(V&0x0F); break;\r
+    case 0xD004: chr_reg[0]=(chr_reg[0]&0x0F)|(V<<4); break;\r
+    case 0xD008: chr_reg[1]=(chr_reg[1]&0xF0)|(V&0x0F); break;\r
+    case 0xD00C: chr_reg[1]=(chr_reg[1]&0x0F)|(V<<4); break;\r
+    case 0xA000: chr_reg[2]=(chr_reg[2]&0xF0)|(V&0x0F); break;\r
+    case 0xA004: chr_reg[2]=(chr_reg[2]&0x0F)|(V<<4); break;\r
+    case 0xA008: chr_reg[3]=(chr_reg[3]&0xF0)|(V&0x0F); break;\r
+    case 0xA00C: chr_reg[3]=(chr_reg[3]&0x0F)|(V<<4); break;\r
+    case 0xB000: chr_reg[4]=(chr_reg[4]&0xF0)|(V&0x0F); break;\r
+    case 0xB004: chr_reg[4]=(chr_reg[4]&0x0F)|(V<<4); break;\r
+    case 0xB008: chr_reg[5]=(chr_reg[5]&0xF0)|(V&0x0F); break;\r
+    case 0xB00C: chr_reg[5]=(chr_reg[5]&0x0F)|(V<<4); break;\r
+    case 0xE000: chr_reg[6]=(chr_reg[6]&0xF0)|(V&0x0F); break;\r
+    case 0xE004: chr_reg[6]=(chr_reg[6]&0x0F)|(V<<4); break;\r
+    case 0xE008: chr_reg[7]=(chr_reg[7]&0xF0)|(V&0x0F); break;\r
+    case 0xE00C: chr_reg[7]=(chr_reg[7]&0x0F)|(V<<4); break;\r
+//    case 0xF004: IRQCount=((IRQCount&0xF0)|(V&0xF)); break;\r
+//    case 0xF000: IRQCount=((IRQCount&0x0F)|((V&0xF)<<4)); break;\r
+    case 0xF008: IRQa=V&2; X6502_IRQEnd(FCEU_IQEXT); break;\r
+//    case 0xF00C: IRQPre=16; break;\r
+    default:\r
+      FCEU_printf("bs %04x %02x\n",A,V);\r
+  }\r
+  Sync();\r
+}\r
+\r
+static DECLFW(UNLCITYFIGHTWriteLo)\r
+{\r
+      FCEU_printf("bs %04x %02x\n",A,V);\r
+}\r
+\r
+static void UNLCITYFIGHTIRQ(void)\r
+{\r
+  //if(IRQa)\r
+  {\r
+//    IRQCount--;\r
+//    if((IRQCount>>1)==0)\r
+//      X6502_IRQBegin(FCEU_IQEXT);\r
+//    if(scanline==100) X6502_IRQBegin(FCEU_IQEXT);\r
+  }\r
+}\r
+\r
+static void UNLCITYFIGHTPower(void)\r
+{\r
+  prg_reg = 0;\r
+  Sync();\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x4020,0x7FFF,UNLCITYFIGHTWriteLo);\r
+  SetWriteHandler(0x8000,0xFFFF,UNLCITYFIGHTWrite);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void UNLCITYFIGHT_Init(CartInfo *info)\r
+{\r
+  info->Power=UNLCITYFIGHTPower;\r
+  GameHBIRQHook=UNLCITYFIGHTIRQ;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
diff --git a/boards/copyfami_emu.c b/boards/copyfami_emu.c
new file mode 100644 (file)
index 0000000..353d78b
--- /dev/null
@@ -0,0 +1,380 @@
+/* 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ */\r
+\r
+#ifdef COPYFAMI\r
+\r
+#include "__serial.h"\r
+#include "mapinc.h"\r
+#include "mmc3.h"\r
+\r
+//#define DEBUG_SERIAL\r
+\r
+// *** COPY FAMICOM EMULATION ***\r
+\r
+/*\r
+Êàðòà ïàìÿòè\r
+\r
+       $0000-$1FFF Îñíîâíîå ÎÇÓ\r
+       $2000-$200F Ðåãèñòðû PPU\r
+       $2010-$3FFB Ñèñòåìíîå ÎÇÓ\r
+       $3FFC-$3FFF Ñèñòåìíûå ðåãèñòðû\r
+       $4000-$7FFF APU ðåãèñòðû/ñâîáîäíî\r
+       $8000-$FFF9 CART/ROM\r
+       $FFFA-$FFFB CART/Âåêòîð NMI\r
+       $FFFE-$FFFF CART/Âåêòîð IRQ\r
+\r
+Ðåãèñòðû\r
+\r
+       CTRL            R/W     $3FFC   ---aenic        ($00 at reset)\r
+\r
+               c - Ðåæèì êàðòðèäæà\r
+                       0 - âûêëþ÷åí\r
+                       1 - âêëþ÷åí\r
+               i - Ðåæèì IRQ âåêòîðà\r
+                       0 - îðèãèíàëüíûé âåêòîð\r
+                       1 - âåêòîð ïåðåõâà÷åí\r
+               n - Ðåæèì NMI âåêòîðà\r
+                       0 - îðèãèíàëüíûé âåêòîð\r
+                       1 - âåêòîð ïåðåõâà÷åí\r
+               e - Çàïðåò NMI\r
+                       0 - çàïðåùåí\r
+                       1 - ðàçðåøåí\r
+               a - Ðåæèì AROM\r
+                       0 - âûêëþ÷åí\r
+                       1 - âêëþ÷åí\r
+\r
+       BANK            R/W     $3FFD   ---mbbbb\r
+\r
+               b - Íîìåð áàíêà âíóòðåííåîãî ÏÇÓ\r
+               m - Ìèððîðèíã â ðåæèìå ÀROM\r
+\r
+       USBDATA         R/W     $3FFE   dddddddd\r
+\r
+               d - Áàéò äàííûõ ïðèåìà/ïåðåäà÷è\r
+\r
+       STATUS          R       $3FFF   vmnicptr\r
+\r
+               r - Ñòàòóñ äàííûõ äëÿ ÷òåíèÿ èç USB\r
+                       0 - Åñòü äàííûå\r
+                       1 - Íåò äàííûõ\r
+               t - Ñòàòóñ áóôåðà äëÿ çàïèñè â USB\r
+                       0 - Åñòü ìåñòî\r
+                       1 - Íåò ìåñòà\r
+               p - Ñòàòóñ ïîäêëþ÷åíèÿ USB êàáåëÿ\r
+                       0 - Ïîäêëþ÷åí\r
+                       1 - Îòêëþ÷åí\r
+               c - Íàëè÷èå êàðòðèäæà â ñëîòå\r
+                       0 - Ïðèñóòñòâóåò\r
+                       1 - Îòñóòñòâóåò\r
+               i - Ñîñòîÿíèå ñèãíàëà IRQ êàðòðèäæà\r
+                       0 - Àêòèâåí\r
+                       1 - Íåàêòèâåí\r
+               n - Ñîñòîÿíèå ñèãíàëà NMI êàðòðèäæà\r
+                       0 - Àêòèâåí\r
+                       1 - Íåàêòèâåí\r
+               m - Ñîñòîÿíèå àäðåñíîé øèíû À10 VRAM (ìèððîðèíã)\r
+               v - Ñîñòîÿíèå VRAM\r
+                       0 - Âûáðàíà\r
+                       1 - Íå âûáðàíà\r
+\r
+Ðåæèì AROM\r
+\r
+       Àêòèâèðóåòñÿ âíóòðåííÿÿ VRAM\r
+       Ðåãèñòðû áàíêîâ è ìèððîðèíãà íà 8000-FFFF\r
+*/\r
+\r
+#define CTRL     0x00\r
+#define  CCART   0x01\r
+#define  CVIRQ   0x02\r
+#define  CVNMI   0x04\r
+#define  CDNMI   0x08\r
+#define  CAROM   0x10\r
+#define BANK     0x01\r
+#define  BMIRR   0x10\r
+#define USB      0x02\r
+#define STATUS   0x03\r
+#define  SRX     0x01\r
+#define  STX     0x02\r
+#define  SPEN    0x04\r
+#define  SCART   0x08\r
+#define  SIRQ    0x10\r
+#define  SNMI    0x20\r
+#define  SA10    0x40\r
+#define  SVRAM   0x80\r
+\r
+#ifdef DEBUG_SERIAL\r
+static uint8 debug_serial_data[] = { \r
+       0xDE, 0xAD, 0xBE, 0xEF, 0x00,\r
+       0xDE, 0xAD, 0xBE, 0xEF, 0x01,\r
+      \r
+       0x02,\r
+\r
+       0x14, 0x50, 0xB0,\r
+       \r
+       0x02,\r
+\r
+       0x14, 0x50, 0xB0,\r
+\r
+       0x02,\r
+\r
+       };\r
+static uint32 debug_serial_data_size = sizeof(debug_serial_data);\r
+static uint32 debug_serial_data_pos;\r
+#endif\r
+\r
+static uint8 *CHRRAM=NULL;\r
+static uint32 CHRRAMSIZE;\r
+\r
+static uint8 regs[4];\r
+\r
+static readfunc def_read_ram, def_read_rom;\r
+static writefunc def_write_ram;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {regs, 4, "CREGS"},\r
+  {0}\r
+};\r
+\r
+static void Sync()\r
+{\r
+  FixMMC3PRG(MMC3_cmd);\r
+  FixMMC3CHR(MMC3_cmd);\r
+}\r
+\r
+static void MCopyFamiMMC3PW(uint32 A, uint8 V)\r
+{\r
+  if(regs[CTRL] & CCART)\r
+    setprg8(A,V);\r
+  else\r
+    setprg32r(1,0x8000,(regs[BANK]&0x0F)^0x08);\r
+}\r
+\r
+static void MCopyFamiMMC3CW(uint32 A, uint8 V)\r
+{\r
+  if((regs[STATUS] & SCART) && (regs[CTRL] & CAROM))\r
+    setchr8r(0x10,0);\r
+  else\r
+    setchr1r(0,A,V);\r
+}\r
+\r
+static void MCopyFamiMMC3MW(uint8 V)\r
+{\r
+  if(regs[CTRL] & CAROM)\r
+  {\r
+    setmirror(MI_0+((regs[BANK]>>4)&1));\r
+  }\r
+  else\r
+  {\r
+    A000B=V;\r
+    setmirror((V&1)^1);\r
+  }\r
+}\r
+\r
+static uint32 direction = 0xffffffff;\r
+static uint32 bytes_count = 0;\r
+\r
+static DECLFW(MCopyFamiWriteReg)\r
+{\r
+  if(((A&3) == USB)&&!fceuindbg) {\r
+    if(direction != 0) {\r
+      direction = 0;\r
+      bytes_count = 0;\r
+      FCEU_printf(" >");\r
+    }\r
+#ifndef DEBUG_SERIAL\r
+    while (!SerialSendChar(V)) {};\r
+#endif\r
+    bytes_count++;\r
+//    FCEU_printf(" %02X",V);\r
+  }\r
+  else\r
+  {\r
+    regs[A&3]=V;\r
+    Sync();\r
+  }\r
+}\r
+\r
+static DECLFR(MCopyFamiReadReg)\r
+{\r
+#ifdef DEBUG_SERIAL\r
+  if(debug_serial_data_pos == debug_serial_data_size)\r
+    regs[STATUS] |= SRX;\r
+  else\r
+    regs[STATUS] &= ~SRX;\r
+#endif\r
+  if (!fceuindbg) \r
+  {\r
+#ifndef DEBUG_SERIAL\r
+    if((A&3) == STATUS)\r
+    {\r
+      int data;\r
+      if((data = SerialGetChar()) == EOF)\r
+        regs[STATUS] |= SRX;\r
+      else\r
+        regs[STATUS] &= ~SRX;\r
+      regs[USB] = data & 0xff;\r
+    } else\r
+#endif\r
+    if((A&3) == USB)\r
+    {\r
+#ifdef DEBUG_SERIAL\r
+      regs[USB] = debug_serial_data[debug_serial_data_pos++];\r
+#endif\r
+      if(direction != 1) {\r
+        if(direction != 0xffffffff) FCEU_printf(" bytes sent: %08x",bytes_count);\r
+        direction = 1;\r
+        bytes_count = 0;\r
+        FCEU_printf("\n<");\r
+      }\r
+    FCEU_printf(" %02X",regs[USB]);\r
+    }\r
+  }\r
+  return regs[A&3];\r
+}\r
+\r
+static DECLFW(MCopyFamiMMC3Write)\r
+{\r
+  if(regs[CTRL] & CAROM)\r
+  {\r
+    regs[BANK] = V & 0x1F;\r
+    Sync();\r
+  }\r
+  else\r
+  {\r
+    if(A >= 0xC000)\r
+     MMC3_IRQWrite(A,V);\r
+    else\r
+     MMC3_CMDWrite(A,V);\r
+  }\r
+}\r
+\r
+static DECLFW(MCopyFamiMMC3WriteNMI)\r
+{\r
+  if(regs[CTRL] & CVNMI)\r
+    def_write_ram(0x3FFC + (A & 1), V);\r
+  else\r
+    MCopyFamiMMC3Write(A, V);\r
+}\r
+\r
+static DECLFW(MCopyFamiMMC3WriteIRQ)\r
+{\r
+  if(regs[CTRL] & CVIRQ)\r
+    def_write_ram(0x3FFE + (A & 1), V);\r
+  else\r
+    MCopyFamiMMC3Write(A, V);\r
+}\r
+\r
+static DECLFR(MCopyFamiReadNMI)\r
+{\r
+  if(regs[CTRL] & CVNMI)\r
+    return def_read_ram(0x3FFC + (A & 1));\r
+  else\r
+    return def_read_rom(A);\r
+}\r
+\r
+static DECLFR(MCopyFamiReadIRQ)\r
+{\r
+  if(regs[CTRL] & CVIRQ)\r
+    return def_read_ram(0x3FFE + (A & 1));\r
+  else\r
+    return def_read_rom(A);\r
+}\r
+\r
+static void MCopyFamiMMC3Power(void)\r
+{\r
+  regs[CTRL] = regs[USB] = 0;\r
+  regs[STATUS] = SIRQ | SNMI | SVRAM;\r
+  regs[BANK] = 0x08;\r
+#ifdef DEBUG_SERIAL\r
+  debug_serial_data_pos = 0;\r
+#endif\r
+  GenMMC3Power();\r
+  Sync();\r
+\r
+  def_write_ram = GetWriteHandler(0x3FFC);\r
+  SetWriteHandler(0x3FFC,0x3FFF,MCopyFamiWriteReg);\r
+  def_read_ram = GetReadHandler(0x3FFC);\r
+  SetReadHandler(0x3FFC,0x3FFF,MCopyFamiReadReg);\r
+\r
+  SetWriteHandler(0x8000,0xFFF9,MCopyFamiMMC3Write);\r
+  SetWriteHandler(0xFFFA,0xFFFB,MCopyFamiMMC3WriteNMI);\r
+  SetWriteHandler(0xFFFE,0xFFFF,MCopyFamiMMC3WriteIRQ);\r
+\r
+  def_read_rom = GetReadHandler(0xFFFA);\r
+  SetReadHandler(0xFFFA,0xFFFB,MCopyFamiReadNMI);\r
+  SetReadHandler(0xFFFE,0xFFFF,MCopyFamiReadIRQ);\r
+}\r
+\r
+static void MCopyFamiMMC3Reset(void)\r
+{\r
+  regs[CTRL] = regs[USB] = 0;\r
+  regs[STATUS] = SIRQ | SNMI | SVRAM;\r
+  regs[BANK] = 0x08;\r
+#ifdef DEBUG_SERIAL\r
+  debug_serial_data_pos = 0;\r
+#endif\r
+  MMC3RegReset();\r
+  Sync();\r
+}\r
+\r
+static void MCopyFamiClose(void)\r
+{\r
+  if(CHRRAM)\r
+    FCEU_gfree(CHRRAM);\r
+  CHRRAM=NULL;\r
+  SerialClose();\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void MapperCopyFamiMMC3_Init(CartInfo *info)\r
+{\r
+  GenMMC3_Init(info, 512, 512, 8, 0);\r
+\r
+  cwrap=MCopyFamiMMC3CW;\r
+  pwrap=MCopyFamiMMC3PW;\r
+  mwrap=MCopyFamiMMC3MW;\r
+\r
+  info->Reset=MCopyFamiMMC3Reset;\r
+  info->Power=MCopyFamiMMC3Power;\r
+  info->Close=MCopyFamiClose;\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
+#ifndef DEBUG_SERIAL\r
+  FCEU_printf("WAITING FOR PORT...\n");\r
+  \r
+  while(!SerialOpen(20, 921600)) {}\r
+\r
+  FCEU_printf("PORT READY.\n");\r
+#endif\r
+\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
+\r
+#endif\r
diff --git a/boards/copyfami_hwi.c b/boards/copyfami_hwi.c
new file mode 100644 (file)
index 0000000..fb9dad4
--- /dev/null
@@ -0,0 +1,601 @@
+/* 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ */\r
+\r
+// *** COPY FAMICOM HARDWARE INTERFACE ***\r
+\r
+#ifdef COPYFAMI\r
+\r
+#define MESSAGE_LOG\r
+#define NO_CACHE\r
+#define NO_RAM\r
+\r
+#include "__serial.h"\r
+#include "mapinc.h"\r
+\r
+#define FNV_32_PRIME    ((uint32)0x01000193)\r
+\r
+#define CHR_CACHE_SIZE (1024 * 4)\r
+#define WRAM_CACHE_SIZE        (1024 / 2)\r
+#define PRG_CACHE_SIZE (1024 / 4)\r
+#define CMD_CACHE_SIZE (1024 * 128)\r
+\r
+#define CMD_MAX_SIZE    (5)\r
+#define CMD_MAX_RETEST  (16)\r
+#define CMD_MAX_VERIFY  (16)\r
+\r
+static uint8 *WRAM = NULL;\r
+\r
+uint8 InitVector[] =   {0xDE, 0xAD, 0xBE, 0xEF}; // args none,               return DE AD BE EF\r
+uint8 ResetCmd[] =     {0x00};                                  // args none,                           return none\r
+uint8 StateCmd[] =     {0x01};                   // args none,               return 7 bytes status\r
+uint8 StatusCmd[] =    {0x02};                   // args none,               return 32 bytes status\r
+uint8 LoadPlugCmd[] =  {0x03, 0x00, 0x00};       // args 2b size, Nb data    return none\r
+uint8 RunPlugCmd[] =   {0x04};                   // args none,               return none\r
+uint8 RunGameCmd[] =   {0x05};                   // args none,               return none\r
+uint8 NROMSave[] =     {0x06};                   // args none,               return 16b + 32kb + 8kb\r
+\r
+uint8 PRGWBCmd[] =     {0x08, 0x00, 0x00, 0x00}; // args 2b addr, 1b data    return none\r
+uint8 PRGRBCmd[] =     {0x09, 0x00, 0x00};       // args 2b addr             return 1b data\r
+uint8 CHRWBCmd[] =     {0x0A, 0x00, 0x00, 0x00}; // args 2b addr, 1b data    return none\r
+uint8 CHRRBCmd[] =     {0x0B, 0x00, 0x00};       // args 2b addr,            return 1b data\r
+\r
+uint8 PRGSUMCmd[] =    {0x10, 0x00, 0x00};       // args 1b addr, 1b size    return (256 * N)b\r
+uint8 PRG32KSUMCmd[] = {0x10, 0x80, 0x80};       // args 1b addr, 1b size    return 32kb\r
+uint8 PRG16KSUMCmd[] = {0x10, 0x00, 0x40};       // args 1b addr, 1b size    return 16kb\r
+uint8 PRG8KSUMCmd[] =  {0x10, 0x00, 0x20};       // args 1b addr, 1b size    return 8kb\r
+uint8 PRG4KSUMCmd[] =  {0x10, 0x00, 0x10};       // args 1b addr, 1b size    return 4kb\r
+\r
+uint8 CHRSUMCmd[] =    {0x11, 0x00, 0x00};       // args 1b addr, 1b size    return (256 * N)b\r
+uint8 CHR8KSUMCmd[] =  {0x11, 0x00, 0x20};       // args 1b addr, 1b size    return 8kb\r
+uint8 CHR4KSUMCmd[] =  {0x11, 0x00, 0x10};       // args 1b addr, 1b size    return 4kb\r
+uint8 CHR2KSUMCmd[] =  {0x11, 0x00, 0x08};       // args 1b addr, 1b size    return 2kb\r
+uint8 CHR1KSUMCmd[] =  {0x11, 0x00, 0x04};       // args 1b addr, 1b size    return 1kb\r
+\r
+uint8 PRGGetCmd[] =    {0x12, 0x00, 0x00};       // args 1b addr, 1b size    return (256 * N)b\r
+uint8 PRG32KGetCmd[] = {0x12, 0x80, 0x80};       // args 1b addr, 1b size    return 32kb\r
+uint8 PRG16KGetCmd[] = {0x12, 0x00, 0x40};       // args 1b addr, 1b size    return 16kb\r
+uint8 PRG8KGetCmd[] =  {0x12, 0x00, 0x20};       // args 1b addr, 1b size    return 8kb\r
+uint8 PRG4KGetCmd[] =  {0x12, 0x00, 0x10};       // args 1b addr, 1b size    return 4kb\r
+\r
+uint8 CHRGetCmd[] =    {0x13, 0x00, 0x00};       // args 1b addr, 1b size    return (256 * N)b\r
+uint8 CHR8KGetCmd[] =  {0x13, 0x00, 0x20};       // args 1b addr, 1b size    return 8kb\r
+uint8 CHR4KGetCmd[] =  {0x13, 0x00, 0x10};       // args 1b addr, 1b size    return 4kb\r
+uint8 CHR2KGetCmd[] =  {0x13, 0x00, 0x08};       // args 1b addr, 1b size    return 2kb\r
+uint8 CHR1KGetCmd[] =  {0x13, 0x00, 0x04};       // args 1b addr, 1b size    return 1kb\r
+\r
+uint8 CPUTestCmd[] =   {0x14, 0x00, 0x00};       // args 1b addr, 1b size    return (2b + 1b) * N + 3b\r
+\r
+typedef struct {\r
+  int32 mirror;\r
+  int32 chrsum[8];\r
+  int32 prgsum[4];\r
+} SYNC_STATE;\r
+\r
+static SYNC_STATE    state_cur, state_new, state_def;\r
+\r
+typedef struct {\r
+  uint8 *buf;\r
+  int32 count;\r
+} DATA_BANKS;\r
+\r
+static DATA_BANKS  chr_data;\r
+static int32       chr_bank[0x10000];\r
+static DATA_BANKS  prg_data;\r
+static int32       prg_bank[0x10000];\r
+\r
+typedef struct {\r
+  SYNC_STATE   states[CMD_CACHE_SIZE];\r
+  int32        seqs[CMD_CACHE_SIZE][CMD_MAX_SIZE];\r
+  int32        count;\r
+} SYNC_CMDS;\r
+\r
+typedef struct {\r
+  int32        seq[CMD_MAX_SIZE];\r
+  int32        size;\r
+  int32        found;\r
+  uint32       hash;\r
+  uint16       hashf;\r
+} SYNC_CMD;\r
+\r
+static SYNC_CMD     cmd;\r
+static SYNC_CMDS    cmds;\r
+\r
+typedef struct {\r
+  int32 index;\r
+  int32 size;\r
+  int32 retest;\r
+  int32 verify; \r
+} CMD_CACHE;\r
+\r
+static CMD_CACHE   cmd_cache[0x10000];\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {state_cur.chrsum, sizeof(state_cur.chrsum), "CHRREG"},\r
+  {state_cur.prgsum, sizeof(state_cur.prgsum), "ROMREG"},\r
+  {&state_cur.mirror, sizeof(state_cur.mirror), "MIRREG"},\r
+  {0}\r
+};\r
+\r
+#define MI_U 4\r
+\r
+static char *mirror_names[5] = {"Horizontal", "Vertical", "Mirror 0", "Mirror 1", "Unknown mirror"};\r
+static int32 mirror_modes[16] = {\r
+  MI_0, MI_U, MI_U, MI_H, MI_U, MI_V, MI_U, MI_U,\r
+  MI_U, MI_U, MI_U, MI_U, MI_U, MI_U, MI_U, MI_1 };\r
+\r
+#define CHRDEF(slot)   (chr_bank[state_def.chrsum[slot]])\r
+#define PRGDEF(slot)   (prg_bank[state_def.prgsum[slot]])\r
+#define CHRCUR(slot)   (chr_bank[state_cur.chrsum[slot]])\r
+#define PRGCUR(slot)   (prg_bank[state_cur.prgsum[slot]])\r
+#define CHRNEW(slot)   (chr_bank[state_new.chrsum[slot]])\r
+#define PRGNEW(slot)   (prg_bank[state_new.prgsum[slot]])\r
+\r
+static void GetStatus(SYNC_STATE *state)\r
+{\r
+  uint8  resp0;\r
+  uint16 resp1, i;\r
+  SEND(StatusCmd);\r
+  GET(resp0, 1);\r
+  state->mirror = resp0;\r
+  GET(resp0, 1);\r
+  for(i=0; i<8; i++) {\r
+    GET(resp1, 2);\r
+    state->chrsum[i] = resp1;\r
+  }\r
+  for(i=0; i<4; i++) {\r
+    GET(resp1, 2);\r
+    state->prgsum[i] = resp1;\r
+  }  \r
+}\r
+\r
+static int32 FetchNewCHRBank(int32 slot)\r
+{\r
+  FILE *ofile;\r
+  char name[256];\r
+  int32 bank = chr_data.count++;\r
+  CHR1KGetCmd[1] = slot << 2;\r
+  SENDGET(CHR1KGetCmd, chr_data.buf[bank * 1024], 1024);\r
+  sprintf(name,"%04x.chr",bank);\r
+  ofile=fopen(name,"wb");\r
+  fwrite((void *)&chr_data.buf[bank * 1024], 1, 1024, ofile);\r
+  fclose(ofile);\r
+  return bank;\r
+}\r
+\r
+static int32 FetchNewPRGBank(int32 slot)\r
+{\r
+  FILE *ofile;\r
+  char name[256];\r
+  int32 bank = prg_data.count++;\r
+  PRG8KGetCmd[1] = 0x80 + (slot << 5);\r
+  SENDGET(PRG8KGetCmd, prg_data.buf[bank * 8192], 8192);\r
+  sprintf(name,"%04x.prg",bank);\r
+  ofile=fopen(name,"wb");\r
+  fwrite((void *)&prg_data.buf[bank * 8192], 1, 8192, ofile);\r
+  fclose(ofile);\r
+  return bank;\r
+}\r
+\r
+static int CheckStatus(void)\r
+{\r
+  int32 i, ischanged = 0;\r
+  GetStatus(&state_new);\r
+  if(state_cur.mirror != state_new.mirror) {\r
+    state_cur.mirror = state_new.mirror;\r
+#ifdef MESSAGE_LOG\r
+    FCEU_printf(">> mirror changed to %s (%02X)\n",mirror_names[mirror_modes[state_cur.mirror]], state_cur.mirror);\r
+#endif\r
+    ischanged = 1;\r
+  } else {\r
+    state_new.mirror = -1;\r
+  }\r
+  for(i=0; i<8; i++) {\r
+    if(state_cur.chrsum[i] != state_new.chrsum[i]) {\r
+      state_cur.chrsum[i] = state_new.chrsum[i];\r
+      if(CHRCUR(i) == -1) {\r
+        CHRCUR(i) = FetchNewCHRBank(i);\r
+#ifdef MESSAGE_LOG\r
+        FCEU_printf(">> chr[%d] bank %d loaded\n", i, CHRCUR(i));\r
+#endif\r
+      }\r
+#ifdef MESSAGE_LOG\r
+      else\r
+        FCEU_printf(">> chr[%d] bank %d switched\n", i, CHRCUR(i));\r
+#endif\r
+      ischanged = 1;\r
+    } else {\r
+      state_new.chrsum[i] = -1;\r
+    }\r
+  }\r
+  for(i=0; i<4; i++) {\r
+    if(state_cur.prgsum[i] != state_new.prgsum[i]) {\r
+      state_cur.prgsum[i] = state_new.prgsum[i];                                \r
+      if(PRGCUR(i) == -1) {\r
+        PRGCUR(i) = FetchNewPRGBank(i);\r
+#ifdef MESSAGE_LOG\r
+        FCEU_printf(">> prg[%d] bank %d loaded\n", i, PRGCUR(i));\r
+#endif\r
+      }\r
+#ifdef MESSAGE_LOG\r
+      else\r
+        FCEU_printf(">> prg[%d] bank %d switched\n", i, PRGCUR(i));\r
+#endif\r
+      ischanged = 1;\r
+    } else {\r
+      state_new.prgsum[i] = -1;\r
+    }\r
+  }\r
+  return ischanged;\r
+}\r
+\r
+#ifndef NO_CACHE\r
+static void ApplyStatus()\r
+{\r
+  int32 i;\r
+  if ((cmds.states[cmd.found].mirror != -1) && (cmds.states[cmd.found].mirror != state_cur.mirror)) {\r
+    state_cur.mirror = cmds.states[cmd.found].mirror;\r
+    setmirror(mirror_modes[state_cur.mirror]);\r
+#ifdef MESSAGE_LOG\r
+    FCEU_printf(">> mirror changed to %s (%02X)\n",mirror_names[mirror_modes[state_cur.mirror]], state_cur.mirror);\r
+#endif\r
+  }\r
+  for(i=0; i<8; i++) {\r
+    int32 sum = cmds.states[cmd.found].chrsum[i];\r
+    if (sum != -1) {\r
+      if (sum != state_cur.chrsum[i]) {\r
+        state_cur.chrsum[i] = sum;\r
+        setchr1r(1, i * 1024, CHRCUR(i));\r
+#ifdef MESSAGE_LOG\r
+        FCEU_printf(">> chr[%d] bank %d switched\n", i, chr_bank[sum]);\r
+#endif\r
+      }\r
+      else\r
+#ifdef MESSAGE_LOG\r
+        FCEU_printf(">> chr[%d] bank %d switched the same\n", i, chr_bank[sum]);\r
+    }\r
+#endif\r
+  }\r
+  for(i=0; i<4; i++) {\r
+    int32 sum = cmds.states[cmd.found].prgsum[i];\r
+    if (sum != -1) {\r
+      if (sum != state_cur.prgsum[i]) {\r
+        state_cur.prgsum[i] = sum;\r
+        setprg8r(2, 0x8000 + (i * 8192), PRGCUR(i));\r
+#ifdef MESSAGE_LOG\r
+        FCEU_printf(">> prg[%d] bank %d switched\n", i, prg_bank[sum]);\r
+#endif\r
+      }\r
+      else\r
+#ifdef MESSAGE_LOG\r
+        FCEU_printf(">> prg[%d] bank %d switched the same\n", i, prg_bank[sum]);\r
+    }\r
+#endif\r
+  }\r
+}\r
+\r
+static void LogCmd()\r
+{\r
+  int32 i;\r
+  FCEU_printf(">> new cmd size %d [", cmd_cache[cmd.hashf].size);\r
+  for(i=0; i<cmd_cache[cmd.hashf].size; i++)\r
+    FCEU_printf(" %06X",cmds.seqs[cmd.found][i]);\r
+  FCEU_printf(" ], switched to (");    \r
+  if (cmds.states[cmd.found].mirror != -1)\r
+    FCEU_printf(" mirror=%s",mirror_names[mirror_modes[cmds.states[cmd.found].mirror]]);\r
+  for(i=0; i<8; i++)\r
+    if (cmds.states[cmd.found].chrsum[i] != -1)\r
+      FCEU_printf(" chr%d=%02X", i, chr_bank[cmds.states[cmd.found].chrsum[i]]);\r
+  for(i=0; i<4; i++)\r
+    if (cmds.states[cmd.found].prgsum[i] != -1)\r
+      FCEU_printf(" prg%d=%02X", i, prg_bank[cmds.states[cmd.found].prgsum[i]]);\r
+  FCEU_printf(" )\n");    \r
+}\r
+#endif\r
+static void Sync()\r
+{\r
+  setchr1r(1, 0x0000, CHRCUR(0));\r
+  setchr1r(1, 0x0400, CHRCUR(1));\r
+  setchr1r(1, 0x0800, CHRCUR(2));\r
+  setchr1r(1, 0x0C00, CHRCUR(3));\r
+  setchr1r(1, 0x1000, CHRCUR(4));\r
+  setchr1r(1, 0x1400, CHRCUR(5));\r
+  setchr1r(1, 0x1800, CHRCUR(6));\r
+  setchr1r(1, 0x1C00, CHRCUR(7));\r
+#ifndef NO_RAM\r
+  setprg8r(1, 0x6000, 0);\r
+#endif\r
+  setprg8r(2, 0x8000, PRGCUR(0));\r
+  setprg8r(2, 0xA000, PRGCUR(1));\r
+  setprg8r(2, 0xC000, PRGCUR(2));\r
+  setprg8r(2, 0xE000, PRGCUR(3));\r
+  setmirror(mirror_modes[state_cur.mirror]);\r
+}\r
+#ifndef NO_CACHE\r
+static void UpdateCmd(uint32 val)\r
+{\r
+  int32 index;\r
+  if(cmd.size < CMD_MAX_SIZE) {\r
+    index = cmd.size++;\r
+  } else {\r
+    // åñëè äîñòèãíóò ìàêñèìóì äëÿ êîìàíäû, âûáðîñèòü ïîñëåäíóþþ, äîáàâèòü íîâóþ,\r
+       // ïðîäîëæàòü äî áàíêñâè÷èíãà\r
+       cmd.hash = 0;\r
+       for(index = 0; index < (CMD_MAX_SIZE - 1); index++) {\r
+         cmd.seq[index] = cmd.seq[index + 1];\r
+      cmd.hash *= FNV_32_PRIME;\r
+      cmd.hash ^= cmd.seq[index];\r
+       }\r
+  }\r
+    cmd.seq[index] = val;\r
+    cmd.hash *= FNV_32_PRIME;\r
+    cmd.hash ^= val;\r
+    cmd.hashf = (cmd.hash >> 16) ^ (cmd.hash & 0xffff);\r
+    cmd.found = cmd_cache[cmd.hashf].index;\r
+  }\r
+#endif\r
+\r
+static DECLFW(MCopyFamiWrite)\r
+{\r
+#ifndef NO_CACHE\r
+  int32 i;\r
+#endif\r
+\r
+#ifdef MESSAGE_LOG\r
+  FCEU_printf("> WRITE %04X:%02X\n",A,V);\r
+#endif\r
+\r
+  PRGWBCmd[1] = A & 0xFF;\r
+  PRGWBCmd[2] = A >> 8;\r
+  PRGWBCmd[3] = V & 0xFF;\r
+  SEND(PRGWBCmd);\r
+#ifdef NO_CACHE\r
+  CheckStatus();\r
+  Sync();\r
+#else\r
+  UpdateCmd((A << 8) | V);\r
+  // èùåì êîìàíäó â êåøå\r
+  if(cmd.found == -1) {\r
+    // íå íàéäåíà, ïðîâåðÿåì, èçìåíèëîñü ëè ñîñòîÿíèå áàíêîâ\r
+    // ëèáî íå ïðåäåëüíîé ëè îíà äëèíû äëÿ êîìàíäû\r
+    cmd_cache[cmd.hashf].index = cmd.found = cmds.count++;\r
+    cmd_cache[cmd.hashf].retest = 0;\r
+    cmd_cache[cmd.hashf].verify = 0;\r
+    for(i=0; i<cmd.size; i++)\r
+      cmds.seqs[cmd.found][i] = cmd.seq[i];\r
+    cmd_cache[cmd.hashf].size = cmd.size;\r
+    if(CheckStatus()) {\r
+      cmds.states[cmd.found] = state_new;\r
+      LogCmd();\r
+      cmd.size = 0;\r
+      cmd.hash = 0;\r
+      Sync();\r
+    } else {\r
+      // åñëè äîáàâëåíà ïîëíàÿ êîìàíäà áåç áàíêñâèò÷èíãà\r
+      cmd_cache[cmd.hashf].index = -2;\r
+    }\r
+  } else if(cmd.found == -2) {\r
+    // ÷àñòè÷íîå ñîâïàäåíèå, åñëè ÷èñëî ïðîâåðîê íå ïðåâûñèëî ëèìèò\r
+    if(cmd_cache[cmd.hashf].retest < CMD_MAX_RETEST) {\r
+      // òî ïðîâåðèì ñîñòîÿíèå áàíêîâ\r
+      if(CheckStatus()) {\r
+        // èçìåíèëîñü, çàïèøåì íîâóþ êîìàíäó\r
+        cmd_cache[cmd.hashf].index = cmd.found = cmds.count++;\r
+        cmd_cache[cmd.hashf].retest = 0;\r
+        cmd_cache[cmd.hashf].verify = 0;\r
+        for(i=0; i<cmd.size; i++)\r
+          cmds.seqs[cmd.found][i] = cmd.seq[i];\r
+        cmd_cache[cmd.hashf].size = cmd.size;\r
+        cmds.states[cmd.found] = state_new;\r
+        LogCmd();\r
+        cmd.size = 0;\r
+        cmd.hash = 0;\r
+        Sync();\r
+      } else {\r
+        // íå èçìåíèëîñü, îòìåòèì óâåëè÷èì ñ÷åò÷èê ïðîâåðîê\r
+        cmd_cache[cmd.hashf].retest++;\r
+      }\r
+    }\r
+  } else {\r
+    // íàéäåíà, ïîñëåäíèé ðóáåæ îáîðîíû îò ãîâíà\r
+/*\r
+    if(cmd_cache[cmd.hashf].verify < CMD_MAX_VERIFY) {\r
+      if(CheckStatus()) {\r
+        int32 changed = 0;\r
+      // åñëè åñòü èçìåíåíèÿ, ñðàâíèì íîâîå ñîñòîÿíèå ñ çàïèñàííûì\r
+        if(cmds.states[cmd.found].mirror != state_new.mirror)\r
+          changed = 1;\r
+        for(i=0; i<8; i++)\r
+          if(cmds.states[cmd.found].chrsum[i] != state_new.chrsum[i])\r
+            changed = 1;\r
+        for(i=0; i<4; i++)\r
+          if(cmds.states[cmd.found].prgsum[i] != state_new.prgsum[i])\r
+            changed = 1;\r
+        if(changed) {\r
+          cmd_cache[cmd.hashf].index = -1;\r
+          cmd_cache[cmd.hashf].retest = 0;\r
+          cmd_cache[cmd.hashf].verify = 0;\r
+          Sync();\r
+        }\r
+      } else\r
+        cmd_cache[cmd.hashf].verify++;\r
+    } else */ {\r
+      // ïðèìåíÿåì áåç ìàëåéøåãî çàçðåíèÿ ñîâåñòè\r
+      ApplyStatus();\r
+      cmd.size = 0;\r
+      cmd.hash = 0;\r
+    }\r
+  }\r
+#endif\r
+}\r
+\r
+static DECLFR(MCopyFamiRead)\r
+{\r
+  uint8 result;\r
+  PRGRBCmd[1] = A & 0xFF;\r
+  PRGRBCmd[2] = A >> 8;\r
+  SENDGET(PRGRBCmd, result, 1);\r
+#ifdef MESSAGE_LOG\r
+  FCEU_printf("> READ %04X:%02X\n",A,result);\r
+#endif\r
+  return result;\r
+}\r
+\r
+static void MCopyFamiReset(void)\r
+{\r
+  state_cur = state_def;\r
+  Sync();\r
+}\r
+\r
+static void MCopyFamiPower(void)\r
+{\r
+//  uint32 resp, presp;\r
+\r
+  FCEU_printf("NOW POWERING... ");\r
+  \r
+  Sync();\r
+  \r
+  SetWriteHandler(0x4018, 0x7fff, MCopyFamiWrite);\r
+  SetReadHandler(0x4018, 0x7fff, MCopyFamiRead);\r
+#ifndef NO_RAM\r
+  SetWriteHandler(0x6000, 0x7fff, CartBW);\r
+  SetReadHandler(0x6000, 0x7fff, CartBR);\r
+#endif\r
+\r
+/*\r
+  FCEU_printf("READING MEMORY MAP...\n");\r
+  CPUTestCmd[1] = 0x50;\r
+  CPUTestCmd[2] = 0x30;\r
+  SEND(CPUTestCmd);\r
+  resp = 0;\r
+  presp = 0xffffffff;\r
+  while (presp != 0x00ff0000) {\r
+    GET(resp, 3);\r
+    if(presp != 0xffffffff) {\r
+      switch(presp & 0x00FF0000) {\r
+        case 0x00000000: // BUS\r
+          FCEU_printf("  %04X-%04X OPEN BUS\n",presp & 0x7fff, (resp - 1) & 0x7fff);\r
+          break;\r
+        case 0x00010000: // RAM\r
+          FCEU_printf("  %04X-%04X RAM\n",presp & 0x7fff, (resp - 1) & 0x7fff);\r
+          SetWriteHandler(presp & 0x7fff, (resp - 1) & 0x7fff, CartBW);\r
+          SetReadHandler(presp & 0x7fff, (resp - 1) & 0x7fff, CartBR);\r
+          break;\r
+      }      \r
+    }\r
+    presp = resp;\r
+  }\r
+*/\r
+  SetWriteHandler(0x8000, 0xffff, MCopyFamiWrite);\r
+  SetReadHandler(0x8000, 0xffff, CartBR);\r
+\r
+  FCEU_printf("DONE!\nNOW COLLECTING DATA...\n");\r
+}\r
+\r
+static void MCopyFamiClose(void)\r
+{\r
+  if(chr_data.buf)\r
+    FCEU_gfree(chr_data.buf);\r
+  chr_data.buf=NULL;\r
+  if(prg_data.buf)\r
+    FCEU_gfree(prg_data.buf);\r
+  prg_data.buf=NULL;\r
+  if(WRAM)\r
+    FCEU_gfree(WRAM);\r
+  WRAM = NULL;\r
+  \r
+  SerialClose();\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void MapperCopyFami_Init(CartInfo *info)\r
+{\r
+  uint32 resp = 0, i, size;\r
+\r
+  memset(chr_bank, -1, sizeof(chr_bank));\r
+  memset(prg_bank, -1, sizeof(chr_bank));\r
+  memset(cmd_cache, -1, sizeof(cmd_cache));\r
+  memset(&cmds, 0, sizeof(cmds));\r
+  memset(&cmd, 0, sizeof(cmd));\r
+  \r
+  info->Reset=MCopyFamiReset;\r
+  info->Power=MCopyFamiPower;\r
+  info->Close=MCopyFamiClose;\r
+  GameStateRestore=StateRestore;\r
+\r
+  size = 1024 * CHR_CACHE_SIZE;        // ðàçìåð ñòðàíèöû 1êá\r
+  chr_data.buf = (uint8*)FCEU_gmalloc(size);\r
+  SetupCartCHRMapping(1, chr_data.buf, size, 1); // ïðîâåðÿòü ïïó ðàì, èíà÷å èãðà ìîæåò ïîðòèòü äàííûå\r
+  AddExState(chr_data.buf, size, 0, "CCHR");\r
+\r
+  size = 8192; // ðàçìåð ñòðàíèöû 8êá\r
+  WRAM = (uint8*)FCEU_gmalloc(size);\r
+  SetupCartPRGMapping(1, WRAM, size, 1);\r
+  AddExState(WRAM, size, 0, "CPRM");\r
+\r
+  size = 8192 * PRG_CACHE_SIZE; // ðàçìåð ñòðàíèöû 8êá\r
+  prg_data.buf = (uint8*)FCEU_gmalloc(size);\r
+  SetupCartPRGMapping(2, prg_data.buf, size, 0);\r
+  AddExState(prg_data.buf, size, 0, "CPPR");\r
+\r
+\r
+  FCEU_printf("WAITING FOR SERIAL PORT... ");\r
+  while(!SerialOpen(19, 921600)) { Sleep(500); }\r
+  FCEU_printf("READY!\n");\r
+\r
+  FCEU_printf("WAITING FOR DEVICE... ");\r
+\r
+  while(resp != *(uint32 *)&InitVector[0]) {\r
+    SEND(ResetCmd);\r
+    SENDGET(InitVector, resp, 4);\r
+    Sleep(500);\r
+  }\r
+\r
+  FCEU_printf("READY!\n");\r
+  FCEU_printf("READING STATUS...\n");\r
+  GetStatus(&state_cur);\r
+  FCEU_printf("MIRRORING IS %s (%02X)\n",mirror_names[mirror_modes[state_cur.mirror]], state_cur.mirror);\r
+  FCEU_printf("READING CHR...\n INITIAL STATE:");\r
+    \r
+  for(i=0; i<8; i++) {\r
+    if(CHRCUR(i) == -1)\r
+      CHRCUR(i) = FetchNewCHRBank(i); \r
+    FCEU_printf(" CHR%d=%02X", i, CHRCUR(i));\r
+  }\r
+  FCEU_printf("\n");\r
+      \r
+  FCEU_printf("READING PRG...\n INITIAL STATE:");\r
+  for(i=0; i<4; i++) {\r
+    if(PRGCUR(i) == -1)\r
+      PRGCUR(i) = FetchNewPRGBank(i);\r
+    FCEU_printf(" PRG%d=%02X", i, PRGCUR(i));\r
+  }\r
+  FCEU_printf("\nDONE!\n");\r
+  \r
+  state_def = state_cur;\r
+\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
+\r
+#endif\r
diff --git a/boards/dance2000.c b/boards/dance2000.c
new file mode 100644 (file)
index 0000000..8089270
--- /dev/null
+++ b/