43725da7 |
1 | /* FCE Ultra - NES/Famicom Emulator\r |
2 | *\r |
3 | * Copyright notice for this file:\r |
4 | * Copyright (C) 2012 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r |
19 | */\r |
20 | \r |
21 | #include "mapinc.h"\r |
22 | #include "mmc3.h"\r |
23 | \r |
24 | static void SA9602BPW(uint32 A, uint8 V)\r |
25 | {\r |
26 | setprg8r(EXPREGS[1],A,V&0x3F);\r |
27 | if(MMC3_cmd&0x40)\r |
28 | setprg8r(0,0x8000,~(1));\r |
29 | else\r |
30 | setprg8r(0,0xc000,~(1));\r |
31 | setprg8r(0,0xe000,~(0));\r |
32 | }\r |
33 | \r |
34 | static DECLFW(SA9602BWrite)\r |
35 | {\r |
36 | switch(A & 0xe001)\r |
37 | {\r |
38 | case 0x8000: EXPREGS[0] = V; break;\r |
39 | case 0x8001:\r |
40 | if((EXPREGS[0] & 7) < 6)\r |
41 | {\r |
42 | EXPREGS[1] = V >> 6;\r |
43 | FixMMC3PRG(MMC3_cmd);\r |
44 | }\r |
45 | break;\r |
46 | }\r |
47 | MMC3_CMDWrite(A, V);\r |
48 | }\r |
49 | \r |
50 | static void SA9602BPower(void)\r |
51 | {\r |
52 | EXPREGS[0]=EXPREGS[1]=0;\r |
53 | GenMMC3Power();\r |
54 | SetReadHandler(0x8000,0xFFFF,CartBR);\r |
55 | SetWriteHandler(0x8000,0xBFFF,SA9602BWrite);\r |
56 | }\r |
57 | \r |
58 | void SA9602B_Init(CartInfo *info)\r |
59 | {\r |
60 | GenMMC3_Init(info, 512, 0, 0, 0);\r |
61 | pwrap=SA9602BPW;\r |
62 | mmc3opts|=2;\r |
63 | info->SaveGame[0]=UNIFchrrama;\r |
64 | info->SaveGameLen[0]=32 * 1024;\r |
65 | info->Power=SA9602BPower;\r |
66 | AddExState(EXPREGS, 2, 0, "EXPR");\r |
67 | }\r |