random warning fixes
[fceu.git] / boards / 187.c
CommitLineData
386f5371 1/* FCE Ultra - NES/Famicom Emulator\r
2 *\r
3 * Copyright notice for this file:\r
4 * Copyright (C) 2005 CaH4e3\r
5 *\r
6 * This program is free software; you can redistribute it and/or modify\r
7 * it under the terms of the GNU General Public License as published by\r
8 * the Free Software Foundation; either version 2 of the License, or\r
9 * (at your option) any later version.\r
10 *\r
11 * This program is distributed in the hope that it will be useful,\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
14 * GNU General Public License for more details.\r
15 *\r
16 * You should have received a copy of the GNU General Public License\r
17 * along with this program; if not, write to the Free Software\r
43725da7 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
19 *\r
20 * A98402 board, A9711, A9746 similar\r
21 * King of Fighters 96, The (Unl), Street Fighter Zero 2 (Unl)\r
22 * \r
386f5371 23 */\r
24\r
25#include "mapinc.h"\r
26#include "mmc3.h"\r
27\r
28static void M187CW(uint32 A, uint8 V)\r
29{\r
30 if((A&0x1000)==((MMC3_cmd&0x80)<<5))\r
31 setchr1(A,V|0x100);\r
32 else\r
33 setchr1(A,V);\r
34}\r
35\r
36static void M187PW(uint32 A, uint8 V)\r
37{\r
38 if(EXPREGS[0]&0x80)\r
39 {\r
40 uint8 bank=EXPREGS[0]&0x1F;\r
41 if(EXPREGS[0]&0x20)\r
43725da7 42 {\r
43 if(EXPREGS[0]&0x40)\r
44 setprg32(0x8000,bank>>2);\r
45 else\r
46 setprg32(0x8000,bank>>1); // hacky hacky! two mappers in one! need real hw carts to test\r
47 }\r
386f5371 48 else\r
49 {\r
50 setprg16(0x8000,bank);\r
51 setprg16(0xC000,bank);\r
52 }\r
53 }\r
54 else\r
55 setprg8(A,V&0x3F);\r
56}\r
57\r
58static DECLFW(M187Write8000)\r
59{\r
43725da7 60 EXPREGS[1]=1;\r
386f5371 61 MMC3_CMDWrite(A,V);\r
62}\r
63\r
64static DECLFW(M187Write8001)\r
65{\r
43725da7 66 if(EXPREGS[1])\r
386f5371 67 MMC3_CMDWrite(A,V);\r
68}\r
69\r
386f5371 70static DECLFW(M187WriteLo)\r
71{\r
43725da7 72 if((A==0x5000)||(A==0x6000))\r
386f5371 73 {\r
74 EXPREGS[0]=V;\r
75 FixMMC3PRG(MMC3_cmd);\r
76 }\r
77}\r
78\r
79static uint8 prot_data[4] = { 0x83, 0x83, 0x42, 0x00 };\r
80static DECLFR(M187Read)\r
81{\r
82 return prot_data[EXPREGS[1]&3];\r
83}\r
84\r
85static void M187Power(void)\r
86{\r
43725da7 87 EXPREGS[0]=EXPREGS[1]=0;\r
386f5371 88 GenMMC3Power();\r
89 SetReadHandler(0x5000,0x5FFF,M187Read);\r
43725da7 90 SetWriteHandler(0x5000,0x6FFF,M187WriteLo);\r
386f5371 91 SetWriteHandler(0x8000,0x8000,M187Write8000);\r
92 SetWriteHandler(0x8001,0x8001,M187Write8001);\r
386f5371 93}\r
94\r
95void Mapper187_Init(CartInfo *info)\r
96{\r
97 GenMMC3_Init(info, 256, 256, 0, 0);\r
98 pwrap=M187PW;\r
99 cwrap=M187CW;\r
100 info->Power=M187Power;\r
101 AddExState(EXPREGS, 3, 0, "EXPR");\r
102}\r