--- /dev/null
+/* 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
+ * Mortal Kombat 2 YOKO */\r
+\r
+#include "mapinc.h"\r
+#include "mmc3.h"\r
+\r
+static uint8 reg[8];\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+ {reg, 8, "REGS"},\r
+ {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+// FCEU_printf("(%02x, %02x)\n",reg[3],reg[4]);\r
+ setprg8(0x8000,reg[0]);\r
+ setprg8(0xA000,reg[1]);\r
+ setprg8(0xC000,reg[2]);\r
+ setprg8(0xE000,~0);\r
+// setchr2(0x0000,reg[3]);\r
+// setchr2(0x0800,reg[4]);\r
+// setchr2(0x1000,reg[5]);\r
+// setchr2(0x1800,reg[6]);\r
+ setchr2(0x0000,reg[3]);\r
+ setchr2(0x0800,reg[4]);\r
+ setchr2(0x1000,reg[5]);\r
+ setchr2(0x1800,reg[6]);\r
+}\r
+\r
+static DECLFW(MCN22MWrite)\r
+{\r
+//FCEU_printf("bs %04x %02x\n",A,V);\r
+ switch(A)\r
+ {\r
+ case 0x8c00:\r
+ case 0x8c01:\r
+ case 0x8c02: reg[A&3]=V; break;\r
+ case 0x8d10: reg[3]=V; break;\r
+ case 0x8d11: reg[4]=V; break;\r
+ case 0x8d16: reg[5]=V; break;\r
+ case 0x8d17: reg[6]=V; break;\r
+ }\r
+ Sync();\r
+}\r
+\r
+static void MCN22MPower(void)\r
+{\r
+ reg[0]=reg[1]=reg[2]=0;\r
+ Sync(); \r
+ SetReadHandler(0x8000,0xFFFF,CartBR);\r
+ SetWriteHandler(0x8000,0xFFFF,MCN22MWrite);\r
+}\r
+/*\r
+static void MCN22MIRQHook(void)\r
+{\r
+ int count = IRQCount;\r
+ if(!count || IRQReload)\r
+ {\r
+ IRQCount = IRQLatch;\r
+ IRQReload = 0;\r
+ }\r
+ else\r
+ IRQCount--;\r
+ if(!IRQCount)\r
+ {\r
+ if(IRQa)\r
+ {\r
+ X6502_IRQBegin(FCEU_IQEXT);\r
+ }\r
+ }\r
+}\r
+*/\r
+static void StateRestore(int version)\r
+{\r
+ Sync();\r
+}\r
+\r
+void UNLCN22M_Init(CartInfo *info)\r
+{\r
+ info->Power=MCN22MPower;\r
+// GameHBIRQHook=MCN22MIRQHook;\r
+ GameStateRestore=StateRestore;\r
+ AddExState(&StateRegs, ~0, 0, 0);\r
+}\r