c62d2810 |
1 | /* FCE Ultra - NES/Famicom Emulator |
2 | * |
3 | * Copyright notice for this file: |
4 | * Copyright (C) 2002 Ben Parnell |
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 | |
23 | #define rg mapbyte1 |
24 | static void DoPRG(void) |
25 | { |
26 | int32 b=((rg[0]>>1)&0xF) | ((rg[0]>>3)&0x10) | ((rg[1]&1)<<5); |
27 | if(rg[0]&0x20) // 16 KB |
28 | { |
29 | ROM_BANK16(0x8000,(b<<1)|(rg[0]&1)); |
30 | ROM_BANK16(0xC000,(b<<1)|(rg[0]&1)); |
31 | } |
32 | else |
33 | ROM_BANK32(b); |
c0bf6f9f |
34 | X6502_Rebase(); |
c62d2810 |
35 | } |
36 | |
37 | static DECLFW(Mapper226_write) |
38 | { |
39 | rg[A&1]=V; |
40 | DoPRG(); |
41 | if(A&1) |
42 | { |
43 | if(rg[1]&2) |
44 | PPUCHRRAM=0; // Write protected. |
45 | else |
46 | PPUCHRRAM=0xFF; // Not write protected. |
47 | } |
48 | else |
49 | MIRROR_SET2((rg[0]>>6)&1); |
50 | } |
51 | |
52 | static void M26Reset(void) |
53 | { |
54 | rg[0]=rg[1]=0; |
55 | DoPRG(); |
56 | PPUCHRRAM=0xFF; |
57 | MIRROR_SET2(0); |
58 | } |
59 | |
60 | static void M26Restore(int version) |
61 | { |
62 | DoPRG(); |
63 | if(rg[1]&2) |
64 | PPUCHRRAM=0; // Write protected. |
65 | else |
66 | PPUCHRRAM=0xFF; // Not write protected. |
67 | MIRROR_SET2((rg[0]>>6)&1); |
68 | } |
69 | |
70 | void Mapper226_init(void) |
71 | { |
72 | SetWriteHandler(0x8000,0xffff,Mapper226_write); |
73 | MapperReset=M26Reset; |
74 | GameStateRestore=M26Restore; |
75 | M26Reset(); |
76 | } |
77 | |
78 | #ifdef OLD // What the heck is this?? |
79 | DECLFW(Mapper226_write) |
80 | { |
81 | MIRROR_SET((A>>13)&1); |
82 | VROM_BANK8(A&0x7F); |
83 | if(A&0x1000) |
84 | { |
85 | if(A&0x40) |
86 | { |
87 | ROM_BANK16(0x8000,(((A>>7))<<1)+1); |
88 | ROM_BANK16(0xC000,(((A>>7))<<1)+1); |
89 | } |
90 | else |
91 | { |
92 | ROM_BANK16(0x8000,(((A>>7))<<1)); |
93 | ROM_BANK16(0xC000,(((A>>7))<<1)); |
94 | } |
95 | } |
96 | else |
97 | { |
98 | ROM_BANK32(A>>7); |
99 | } |
100 | } |
101 | |
102 | void Mapper226_init(void) |
103 | { |
104 | SetWriteHandler(0x8000,0xffff,Mapper226_write); |
105 | } |
106 | #endif |