+++ /dev/null
-/* FCE Ultra - NES/Famicom Emulator\r
- *\r
- * Copyright notice for this file:\r
- * Copyright (C) 2007 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
-#include "mapinc.h"\r
-\r
-static uint8 reg[2];\r
-\r
-static uint8 *WRAM=NULL;\r
-static uint32 WRAMSIZE;\r
-\r
-static SFORMAT StateRegs[]=\r
-{\r
- {reg, 2, "REG"},\r
- {0}\r
-};\r
-\r
-static void Sync(void)\r
-{\r
- setchr8(0);\r
- setprg8r(0x10,0x6000,0);\r
- setprg32(0x8000,reg[1]>>1);\r
- setmirror((reg[0]&1)^1);\r
-}\r
-\r
-static DECLFW(M179Write)\r
-{\r
- if(A==0xa000) reg[0]=V;\r
- Sync();\r
-}\r
-\r
-static DECLFW(M179WriteLo)\r
-{\r
- if(A==0x5ff1) reg[1]=V;\r
- Sync();\r
-}\r
-\r
-static void M179Power(void)\r
-{\r
- reg[0]=reg[1]=0;\r
- Sync(); \r
- SetWriteHandler(0x4020,0x5fff,M179WriteLo);\r
- SetReadHandler(0x6000,0x7fff,CartBR);\r
- SetWriteHandler(0x6000,0x7fff,CartBW);\r
- SetReadHandler(0x8000,0xFFFF,CartBR);\r
- SetWriteHandler(0x8000,0xFFFF,M179Write);\r
-}\r
-\r
-static void M179Close(void)\r
-{\r
- if(WRAM)\r
- FCEU_gfree(WRAM);\r
- WRAM=NULL;\r
-}\r
-\r
-static void StateRestore(int version)\r
-{\r
- Sync();\r
-}\r
-\r
-void Mapper179_Init(CartInfo *info)\r
-{\r
- info->Power=M179Power;\r
- info->Close=M179Close;\r
- GameStateRestore=StateRestore;\r
-\r
- WRAMSIZE=8192;\r
- WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);\r
- SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);\r
- AddExState(WRAM, WRAMSIZE, 0, "WRAM");\r
- if(info->battery)\r
- {\r
- info->SaveGame[0]=WRAM;\r
- info->SaveGameLen[0]=WRAMSIZE;\r
- }\r
-\r
- AddExState(&StateRegs, ~0, 0, 0);\r
-}\r