--- /dev/null
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ * Copyright (C) 2009 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 regs[8];\r
+static uint8 *WRAM = NULL;\r
+static uint32 WRAMSIZE;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+ {regs, 8, "REGS"},\r
+ {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+ setprg2r(0x10,0x0800,0);\r
+ setprg2r(0x10,0x1000,1);\r
+ setprg2r(0x10,0x1800,2);\r
+ setprg8r(0x10,0x6000,1);\r
+ setprg16(0x8000,0);\r
+ setprg16(0xC000,~0);\r
+ setchr8(0);\r
+}\r
+\r
+//static DECLFW(SSSNROMWrite)\r
+//{\r
+// CartBW(A,V);\r
+//}\r
+\r
+static DECLFW(SSSNROMWrite)\r
+{\r
+ //FCEU_printf("write %04x %02x\n",A,V);\r
+ //regs[A&7] = V;\r
+}\r
+\r
+static DECLFR(SSSNROMRead)\r
+{\r
+ //FCEU_printf("read %04x\n",A);\r
+ switch(A&7) {\r
+ case 0: return regs[0]=0xff; // clear all exceptions\r
+ case 2: return 0xc0; // DIP selftest + freeplay\r
+ case 3: return 0x00; // 0, 1 - attract\r
+ // 2\r
+ // 4 - menu\r
+ // 8 - self check and game casette check\r
+ // 10 - lock?\r
+ // 20 - game title & count display\r
+ case 7: return 0x22; // TV type, key not turned, relay B\r
+ default: return 0;\r
+ }\r
+}\r
+\r
+static void SSSNROMPower(void)\r
+{\r
+ regs[0]=regs[1]=regs[2]=regs[3]=regs[4]=regs[5]=regs[6]=0;\r
+ regs[7]=0xff;\r
+ Sync();\r
+ memset(WRAM,0x00,WRAMSIZE);\r
+// SetWriteHandler(0x0000,0x1FFF,SSSNROMRamWrite);\r
+ SetReadHandler(0x0800,0x1FFF,CartBR);\r
+ SetWriteHandler(0x0800,0x1FFF,CartBW);\r
+ SetReadHandler(0x5000,0x5FFF,SSSNROMRead);\r
+ SetWriteHandler(0x5000,0x5FFF,SSSNROMWrite);\r
+ SetReadHandler(0x6000,0x7FFF,CartBR);\r
+ SetWriteHandler(0x6000,0x7FFF,CartBW);\r
+ SetReadHandler(0x8000,0xFFFF,CartBR);\r
+}\r
+\r
+static void SSSNROMReset(void)\r
+{\r
+ regs[1]=regs[2]=regs[3]=regs[4]=regs[5]=regs[6]=0;\r
+}\r
+\r
+static void SSSNROMClose(void)\r
+{\r
+ if(WRAM)\r
+ FCEU_gfree(WRAM);\r
+ WRAM=NULL;\r
+}\r
+\r
+static void SSSNROMIRQHook(void)\r
+{\r
+// X6502_IRQBegin(FCEU_IQEXT);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+ Sync();\r
+}\r
+\r
+void SSSNROM_Init(CartInfo *info)\r
+{\r
+ info->Reset=SSSNROMReset;\r
+ info->Power=SSSNROMPower;\r
+ info->Close=SSSNROMClose;\r
+ GameHBIRQHook=SSSNROMIRQHook;\r
+ GameStateRestore=StateRestore;\r
+\r
+ WRAMSIZE=16384;\r
+ WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);\r
+ SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);\r
+\r
+ AddExState(WRAM, WRAMSIZE, 0, "WRAM");\r
+ AddExState(&StateRegs, ~0, 0, 0);\r
+}\r