+++ /dev/null
-/* FCE Ultra - NES/Famicom Emulator\r
- *\r
- * Copyright notice for this file:\r
- * Copyright (C) 2007 CaH4e3\r
- * Copyright (C) 2012 FCEUX team\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
-extern uint32 ROM_size;\r
-\r
-static uint8 prg[4], chr, sbw, we_sram;\r
-static uint8 *WRAM=NULL;\r
-static uint32 WRAMSIZE;\r
-\r
-static SFORMAT StateRegs[]=\r
-{\r
- {prg, 4, "PRG"},\r
- {&chr, 1, "CHR"},\r
- {&sbw, 1, "SBW"},\r
- {0}\r
-};\r
-\r
-static void Sync(void)\r
-{\r
- setprg8r(0x10,0x6000,0);\r
- setprg8(0x8000,prg[0]);\r
- setprg8(0xA000,prg[1]);\r
- setprg8(0xC000,prg[2]);\r
- setprg8(0xE000,prg[3]);\r
-\r
- setchr8(chr);\r
-}\r
-\r
-static DECLFW(M176Write_5001)\r
-{ \r
- printf("%04X = $%02X\n",A,V);\r
- if(sbw)\r
- {\r
- prg[0] = V*4;\r
- prg[1] = V*4+1;\r
- prg[2] = V*4+2;\r
- prg[3] = V*4+3;\r
- }\r
- Sync();\r
-}\r
-\r
-static DECLFW(M176Write_5010)\r
-{ \r
- printf("%04X = $%02X\n",A,V);\r
- if(V == 0x24) sbw = 1;\r
- Sync();\r
-}\r
-\r
-static DECLFW(M176Write_5011)\r
-{ \r
- printf("%04X = $%02X\n",A,V);\r
- V >>= 1;\r
- if(sbw)\r
- {\r
- prg[0] = V*4;\r
- prg[1] = V*4+1;\r
- prg[2] = V*4+2;\r
- prg[3] = V*4+3;\r
- }\r
- Sync();\r
-}\r
-\r
-static DECLFW(M176Write_5FF1)\r
-{ \r
- printf("%04X = $%02X\n",A,V);\r
- V >>= 1;\r
- prg[0] = V*4;\r
- prg[1] = V*4+1;\r
- prg[2] = V*4+2;\r
- prg[3] = V*4+3;\r
- Sync();\r
-}\r
-\r
-static DECLFW(M176Write_5FF2)\r
-{ \r
- printf("%04X = $%02X\n",A,V);\r
- chr = V;\r
- Sync();\r
-}\r
-\r
-static DECLFW(M176Write_A001)\r
-{\r
- we_sram = V & 0x03;\r
-}\r
-\r
-static DECLFW(M176Write_WriteSRAM)\r
-{\r
-// if(we_sram)\r
- CartBW(A,V);\r
-}\r
-\r
-static void M176Power(void)\r
-{\r
- SetReadHandler(0x6000,0x7fff,CartBR);\r
- SetWriteHandler(0x6000,0x7fff,M176Write_WriteSRAM);\r
- SetReadHandler(0x8000,0xFFFF,CartBR);\r
- SetWriteHandler(0xA001,0xA001,M176Write_A001);\r
- SetWriteHandler(0x5001,0x5001,M176Write_5001);\r
- SetWriteHandler(0x5010,0x5010,M176Write_5010);\r
- SetWriteHandler(0x5011,0x5011,M176Write_5011);\r
- SetWriteHandler(0x5ff1,0x5ff1,M176Write_5FF1);\r
- SetWriteHandler(0x5ff2,0x5ff2,M176Write_5FF2);\r
- \r
- we_sram = 0;\r
- sbw = 0;\r
- prg[0] = 0;\r
- prg[1] = 1;\r
- prg[2] = (ROM_size-2)&63;\r
- prg[3] = (ROM_size-1)&63;\r
- Sync();\r
-}\r
-\r
-\r
-static void M176Close(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 Mapper176_Init(CartInfo *info)\r
-{\r
- info->Power=M176Power;\r
- info->Close=M176Close;\r
-\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
- AddExState(&StateRegs, ~0, 0, 0);\r
-}\r