merge mappers from FCEU-mm
[fceu.git] / boards / mmc1.c
index 24a07bc..df7ddf8 100644 (file)
@@ -16,7 +16,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
@@ -24,8 +24,8 @@
 static void GenMMC1Power(void);\r
 static void GenMMC1Init(CartInfo *info, int prg, int chr, int wram, int battery);\r
 \r
-static uint8 DRegs[4];\r
-static uint8 Buffer,BufferShift;\r
+static uint8 BufferShift,DRegs[4];\r
+static uint8 Buffer;\r
 \r
 static int mmc1opts;\r
 \r
@@ -107,39 +107,39 @@ static void MMC1PRG(void)
   else\r
   {\r
     switch(DRegs[0]&0xC)\r
-  {\r
-    case 0xC: setprg16(0x8000,(DRegs[3]+offs));\r
-              setprg16(0xC000,0xF+offs);\r
-              break;\r
-    case 0x8: setprg16(0xC000,(DRegs[3]+offs));\r
-              setprg16(0x8000,offs);\r
-              break;\r
-    case 0x0:\r
-    case 0x4:\r
-              setprg16(0x8000,((DRegs[3]&~1)+offs));\r
-              setprg16(0xc000,((DRegs[3]&~1)+offs+1));\r
-              break;\r
+    {\r
+      case 0xC: setprg16(0x8000,(DRegs[3]+offs));\r
+                setprg16(0xC000,0xF+offs);\r
+                break;\r
+      case 0x8: setprg16(0xC000,(DRegs[3]+offs));\r
+                setprg16(0x8000,offs);\r
+                break;\r
+      case 0x0:\r
+      case 0x4:\r
+                setprg16(0x8000,((DRegs[3]&~1)+offs));\r
+                setprg16(0xc000,((DRegs[3]&~1)+offs+1));\r
+                break;\r
+    }\r
   }\r
 }\r
-}\r
 \r
 static void MMC1MIRROR(void)\r
 {\r
   if(!is171) \r
-  switch(DRegs[0]&3)\r
-  {\r
-    case 2: setmirror(MI_V); break;\r
-    case 3: setmirror(MI_H); break;\r
-    case 0: setmirror(MI_0); break;\r
-    case 1: setmirror(MI_1); break;\r
-  }\r
+    switch(DRegs[0]&3)\r
+    {\r
+      case 2: setmirror(MI_V); break;\r
+      case 3: setmirror(MI_H); break;\r
+      case 0: setmirror(MI_0); break;\r
+      case 1: setmirror(MI_1); break;\r
+    }\r
 }\r
 \r
 static uint64 lreset;\r
 static DECLFW(MMC1_write)\r
 {\r
   int n=(A>>13)-4;\r
-  //FCEU_DispMessage("%016x",0,timestampbase+timestamp);\r
+  //FCEU_DispMessage("%016x",timestampbase+timestamp);\r
 //  FCEU_printf("$%04x:$%02x, $%04x\n",A,V,X.PC);\r
   //DumpMem("out",0xe000,0xffff);\r
 \r
@@ -165,6 +165,7 @@ static DECLFW(MMC1_write)
 \r
   if(BufferShift==5)\r
   {\r
+//    FCEU_printf("REG[%d]=%02x\n",n,Buffer);\r
     DRegs[n] = Buffer;\r
     BufferShift = Buffer = 0;\r
     switch(n)\r
@@ -323,11 +324,6 @@ static void GenMMC1Init(CartInfo *info, int prg, int chr, int wram, int battery)
   if(wram)\r
   {\r
     WRAM=(uint8*)FCEU_gmalloc(wram*1024);\r
-       //mbg 17-jun-08 - this shouldve been cleared to re-initialize save ram\r
-       //ch4 10-dec-08 - nope, this souldn't\r
-       //mbg 29-mar-09 - no time to debate this, we need to keep from breaking some old stuff.\r
-       //we really need to make up a policy for how compatibility and accuracy can be resolved.\r
-       memset(WRAM,0,wram*1024);\r
     mmc1opts|=1;\r
     if(wram>8) mmc1opts|=4;\r
     SetupCartPRGMapping(0x10,WRAM,wram*1024,1);\r
@@ -350,8 +346,6 @@ static void GenMMC1Init(CartInfo *info, int prg, int chr, int wram, int battery)
   info->Power=GenMMC1Power;\r
   GameStateRestore=MMC1_Restore;\r
   AddExState(&lreset, 8, 1, "LRST");\r
-  AddExState(&Buffer, 1, 1, "BFFR");\r
-  AddExState(&BufferShift, 1, 1, "BFRS");\r
 }\r
 \r
 void Mapper1_Init(CartInfo *info)\r