--- /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
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 *WRAM=NULL;\r
+static uint8 reg;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+ {®, 1, "REG"},\r
+ {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+ setchr8(0);\r
+ setprg8r(0x10,0x6000,(reg&0xC0)>>6);\r
+ setprg32(0x8000,reg&0x1F);\r
+// setmirror(((reg&0x20)>>5));\r
+}\r
+\r
+static DECLFW(UNLEDU2000HiWrite)\r
+{\r
+// FCEU_printf("%04x:%02x\n",A,V);\r
+ reg=V;\r
+ Sync();\r
+}\r
+\r
+static void UNLEDU2000Power(void)\r
+{\r
+ setmirror(MI_0);\r
+ SetReadHandler(0x6000,0xFFFF,CartBR);\r
+ SetWriteHandler(0x6000,0xFFFF,CartBW);\r
+ SetWriteHandler(0x8000,0xFFFF,UNLEDU2000HiWrite);\r
+ reg=0;\r
+ Sync();\r
+}\r
+\r
+static void UNLEDU2000Close(void)\r
+{\r
+ if(WRAM)\r
+ FCEU_gfree(WRAM);\r
+ WRAM=NULL;\r
+}\r
+\r
+static void UNLEDU2000Restore(int version)\r
+{\r
+ Sync();\r
+}\r
+\r
+void UNLEDU2000_Init(CartInfo *info)\r
+{\r
+ info->Power=UNLEDU2000Power;\r
+ info->Close=UNLEDU2000Close;\r
+ GameStateRestore=UNLEDU2000Restore;\r
+ WRAM=(uint8*)FCEU_gmalloc(32768);\r
+ SetupCartPRGMapping(0x10,WRAM,32768,1);\r
+ if(info->battery)\r
+ {\r
+ info->SaveGame[0]=WRAM;\r
+ info->SaveGameLen[0]=32768;\r
+ }\r
+ AddExState(WRAM, 32768, 0, "WRAM");\r
+ AddExState(StateRegs, ~0, 0, 0);\r
+}\r