e2d0dd92 |
1 | /* FCE Ultra - NES/Famicom Emulator |
2 | * |
3 | * Copyright notice for this file: |
4 | * Copyright (C) 2005 CaH4e3 |
5 | * |
6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation; either version 2 of the License, or |
9 | * (at your option) any later version. |
10 | * |
11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU General Public License |
17 | * along with this program; if not, write to the Free Software |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | */ |
20 | |
21 | #include "mapinc.h" |
22 | #include "mmc3.h" |
23 | |
24 | //static uint8 *CHRRAM = NULL; |
25 | static int masko8[8]={63,31,15,1,3,0,0,0}; |
26 | |
27 | static void Super24PW(uint32 A, uint8 V) |
28 | { |
29 | uint32 NV=V&masko8[EXPREGS[0]&7]; |
30 | NV|=(EXPREGS[1]<<1); |
31 | setprg8r((NV>>6)&0xF,A,NV); |
32 | } |
33 | |
34 | static void Super24CW(uint32 A, uint8 V) |
35 | { |
36 | if(EXPREGS[0]&0x20) |
37 | setchr1r(0x10,A,V); |
38 | else |
39 | { |
40 | uint32 NV=V|(EXPREGS[2]<<3); |
41 | setchr1r((NV>>9)&0xF,A,NV); |
42 | } |
43 | } |
44 | |
45 | static DECLFW(Super24Write) |
46 | { |
47 | switch(A) |
48 | { |
49 | case 0x5FF0: EXPREGS[0]=V; |
50 | FixMMC3PRG(MMC3_cmd); |
51 | FixMMC3CHR(MMC3_cmd); |
52 | break; |
53 | case 0x5FF1: EXPREGS[1]=V; |
54 | FixMMC3PRG(MMC3_cmd); |
55 | break; |
56 | case 0x5FF2: EXPREGS[2]=V; |
57 | FixMMC3CHR(MMC3_cmd); |
58 | break; |
59 | } |
60 | } |
61 | |
62 | static void Super24Power(void) |
63 | { |
64 | EXPREGS[0]=0x24; |
65 | EXPREGS[1]=159; |
66 | EXPREGS[2]=0; |
67 | GenMMC3Power(); |
68 | SetWriteHandler(0x5000,0x7FFF,Super24Write); |
69 | SetReadHandler(0x8000,0xFFFF,CartBR); |
70 | } |
71 | |
72 | static void Super24Reset(void) |
73 | { |
74 | EXPREGS[0]=0x24; |
75 | EXPREGS[1]=159; |
76 | EXPREGS[2]=0; |
77 | MMC3RegReset(); |
78 | } |
79 | |
80 | static void Super24Close(void) |
81 | { |
82 | if(CHRRAM) |
83 | FCEU_gfree(CHRRAM); |
84 | CHRRAM = NULL; |
85 | } |
86 | |
87 | void Super24_Init(CartInfo *info) |
88 | { |
89 | GenMMC3_Init(info, 128, 256, 0, 0); |
90 | info->Power=Super24Power; |
91 | info->Reset=Super24Reset; |
92 | info->Close=Super24Close; |
93 | cwrap=Super24CW; |
94 | pwrap=Super24PW; |
95 | CHRRAM=(uint8*)FCEU_gmalloc(8192); |
96 | SetupCartCHRMapping(0x10, CHRRAM, 8192, 1); |
97 | AddExState(CHRRAM, 8192, 0, "CHRR"); |
98 | AddExState(EXPREGS, 3, 0, "BIG2"); |
99 | } |