3fb546045854c70e4eacf4803d9fe57691856043
[fceu.git] / boards / a9711.c
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
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
19  */\r
20 \r
21 #include "mapinc.h"\r
22 #include "mmc3.h"\r
23 \r
24 //static uint8 m_perm[8] = {0, 1, 0, 3, 0, 5, 6, 7};\r
25 \r
26 static void UNLA9711PW(uint32 A, uint8 V)\r
27 {\r
28   if((EXPREGS[0]&0xFF) == 0x37)\r
29   {\r
30     setprg8(0x8000, 0x13);\r
31     setprg8(0xA000, 0x13);\r
32     setprg8(0xC000, 0x13);\r
33     setprg8(0xE000, 0x0);\r
34 //    uint8 bank=EXPREGS[0]&0x1F;\r
35 //   if(EXPREGS[0]&0x20)\r
36 //      setprg32(0x8000,bank>>2);\r
37 //    else\r
38 //    {\r
39 //      setprg16(0x8000,bank);\r
40 //      setprg16(0xC000,bank);\r
41 //    }\r
42   }\r
43   else\r
44     setprg8(A,V&0x3F);\r
45 }\r
46 \r
47 //static DECLFW(UNLA9711Write8000)\r
48 //{\r
49 //  FCEU_printf("bs %04x %02x\n",A,V);\r
50 //  if(V&0x80)\r
51 //    MMC3_CMDWrite(A,V);\r
52 //  else\r
53 //    MMC3_CMDWrite(A,m_perm[V&7]);\r
54 //  if(V!=0x86) MMC3_CMDWrite(A,V);\r
55 //}\r
56 \r
57 static DECLFW(UNLA9711WriteLo)\r
58 {\r
59   FCEU_printf("bs %04x %02x\n",A,V);\r
60   EXPREGS[0]=V;\r
61   FixMMC3PRG(MMC3_cmd);\r
62 }\r
63 \r
64 static void UNLA9711Power(void)\r
65 {\r
66   EXPREGS[0]=EXPREGS[1]=EXPREGS[2]=0;\r
67   GenMMC3Power();\r
68   SetWriteHandler(0x5000,0x5FFF,UNLA9711WriteLo);\r
69 //  SetWriteHandler(0x8000,0xbfff,UNLA9711Write8000);\r
70 }\r
71 \r
72 void UNLA9711_Init(CartInfo *info)\r
73 {\r
74   GenMMC3_Init(info, 256, 256, 0, 0);\r
75   pwrap=UNLA9711PW;\r
76   info->Power=UNLA9711Power;\r
77   AddExState(EXPREGS, 3, 0, "EXPR");\r
78 }\r