merge mapper code from FCEUX
[fceu.git] / boards / sheroes.c
index d228a26..8bea1f7 100644 (file)
@@ -1,86 +1,88 @@
-/* FCE Ultra - NES/Famicom Emulator
- *
- * Copyright notice for this file:
- *  Copyright (C) 2006 CaH4e3
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include "mapinc.h"
-#include "mmc3.h"
-
-//static uint8 *CHRRAM;
-static uint8 tekker;
-
-static void MSHCW(uint32 A, uint8 V)
-{
-  if(EXPREGS[0]&0x40)
-    setchr8r(0x10,0);
-  else
-  {
-    if(A<0x800)
-      setchr1(A,V|((EXPREGS[0]&8)<<5));
-    else if(A<0x1000)
-      setchr1(A,V|((EXPREGS[0]&4)<<6));
-    else if(A<0x1800)
-      setchr1(A,V|((EXPREGS[0]&1)<<8));
-    else
-      setchr1(A,V|((EXPREGS[0]&2)<<7));
-  }
-}
-
-static DECLFW(MSHWrite)
-{
-  EXPREGS[0]=V;
-  FixMMC3CHR(MMC3_cmd);
-}
-
-static DECLFR(MSHRead)
-{
-  return(tekker);
-}
-
-static void MSHReset(void)
-{
-  MMC3RegReset();
-  tekker^=0xFF;
-}
-
-static void MSHPower(void)
-{
-  tekker=0x00;
-  GenMMC3Power();
-  SetWriteHandler(0x4100,0x4100,MSHWrite);
-  SetReadHandler(0x4100,0x4100,MSHRead);
-}
-
-static void MSHClose(void)
-{
-  if(CHRRAM)
-    FCEU_gfree(CHRRAM);
-  CHRRAM=NULL;
-}
-
-void UNLSHeroes_Init(CartInfo *info)
-{
-  GenMMC3_Init(info, 256, 512, 0, 0);
-  cwrap=MSHCW;
-  info->Power=MSHPower;
-  info->Reset=MSHReset;
-  info->Close=MSHClose;
-  CHRRAM = (uint8*)FCEU_gmalloc(8192);
-  SetupCartCHRMapping(0x10, CHRRAM, 8192, 1);
-  AddExState(EXPREGS, 4, 0, "EXPR");
-}
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2006 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+#include "mmc3.h"\r
+\r
+static uint8 *CHRRAM;           // there is no more extern CHRRAM in mmc3.h
+                                                        // I need chrram here and local   static == local\r
+static uint8 tekker;\r
+\r
+static void MSHCW(uint32 A, uint8 V)\r
+{\r
+  if(EXPREGS[0]&0x40)\r
+    setchr8r(0x10,0);\r
+  else\r
+  {\r
+    if(A<0x800)\r
+      setchr1(A,V|((EXPREGS[0]&8)<<5));\r
+    else if(A<0x1000)\r
+      setchr1(A,V|((EXPREGS[0]&4)<<6));\r
+    else if(A<0x1800)\r
+      setchr1(A,V|((EXPREGS[0]&1)<<8));\r
+    else\r
+      setchr1(A,V|((EXPREGS[0]&2)<<7));\r
+  }\r
+}\r
+\r
+static DECLFW(MSHWrite)\r
+{\r
+  EXPREGS[0]=V;\r
+  FixMMC3CHR(MMC3_cmd);\r
+}\r
+\r
+static DECLFR(MSHRead)\r
+{\r
+  return(tekker);\r
+}\r
+\r
+static void MSHReset(void)\r
+{\r
+  MMC3RegReset();\r
+  tekker^=0xFF; \r
+}\r
+\r
+static void MSHPower(void)\r
+{\r
+  tekker=0x00;\r
+  GenMMC3Power();\r
+  SetWriteHandler(0x4100,0x4100,MSHWrite);\r
+  SetReadHandler(0x4100,0x4100,MSHRead);\r
+}\r
+\r
+static void MSHClose(void)\r
+{\r
+  if(CHRRAM)\r
+    FCEU_gfree(CHRRAM);\r
+  CHRRAM=NULL;\r
+}\r
+\r
+void UNLSHeroes_Init(CartInfo *info)\r
+{\r
+  GenMMC3_Init(info, 256, 512, 0, 0);\r
+  cwrap=MSHCW;\r
+  info->Power=MSHPower;\r
+  info->Reset=MSHReset;\r
+  info->Close=MSHClose;\r
+  CHRRAM = (uint8*)FCEU_gmalloc(8192);\r
+  SetupCartCHRMapping(0x10, CHRRAM, 8192, 1);\r
+  AddExState(EXPREGS, 4, 0, "EXPR");\r
+  AddExState(&tekker, 1, 0, "DIPSW");\r
+}\r