--- /dev/null
+/* 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
+ {®, 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