c62d2810 |
1 | /* FCE Ultra - NES/Famicom Emulator |
2 | * |
3 | * Copyright notice for this file: |
d97315ac |
4 | * Copyright (C) 2002 Xodnizel |
c62d2810 |
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 |
43725da7 |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
c62d2810 |
19 | */ |
20 | |
21 | #include "mapinc.h" |
22 | |
d97315ac |
23 | static uint32 lastA; |
24 | static int isfu; |
25 | static uint8 CCache[8]; |
c62d2810 |
26 | |
43725da7 |
27 | static void FP_FASTAPASS(1) Fudou_PPU(uint32 A) |
d97315ac |
28 | { |
29 | static int last=-1; |
30 | static uint8 z; |
31 | |
32 | if(A>=0x2000) return; |
33 | |
34 | A>>=10; |
35 | lastA=A; |
36 | |
37 | z=CCache[A]; |
38 | if(z!=last) |
39 | { |
40 | onemir(z); |
41 | last=z; |
42 | } |
43 | } |
44 | |
45 | static void mira() |
46 | { |
47 | if(isfu) |
48 | { |
49 | int x; |
50 | CCache[0]=CCache[1]=mapbyte2[0]>>7; |
51 | CCache[2]=CCache[3]=mapbyte2[1]>>7; |
c62d2810 |
52 | |
d97315ac |
53 | for(x=0;x<4;x++) |
54 | CCache[4+x]=mapbyte2[2+x]>>7; |
55 | |
56 | onemir(CCache[lastA]); |
57 | } |
58 | else |
59 | MIRROR_SET2(mapbyte1[0]&1); |
60 | } |
61 | |
62 | static DECLFW(Mapper80_write) |
c62d2810 |
63 | { |
d97315ac |
64 | switch(A) |
c62d2810 |
65 | { |
d97315ac |
66 | case 0x7ef0: mapbyte2[0]=V;VROM_BANK2(0x0000,(V>>1)&0x3F);mira();break; |
67 | case 0x7ef1: mapbyte2[1]=V;VROM_BANK2(0x0800,(V>>1)&0x3f);mira();break; |
c62d2810 |
68 | |
d97315ac |
69 | case 0x7ef2: mapbyte2[2]=V;VROM_BANK1(0x1000,V);mira();break; |
70 | case 0x7ef3: mapbyte2[3]=V;VROM_BANK1(0x1400,V);mira();break; |
71 | case 0x7ef4: mapbyte2[4]=V;VROM_BANK1(0x1800,V);mira();break; |
72 | case 0x7ef5: mapbyte2[5]=V;VROM_BANK1(0x1c00,V);mira();break; |
73 | case 0x7ef6: mapbyte1[0]=V;mira();break; |
c62d2810 |
74 | case 0x7efa: |
d97315ac |
75 | case 0x7efb: ROM_BANK8(0x8000,V);break; |
c62d2810 |
76 | case 0x7efd: |
d97315ac |
77 | case 0x7efc: ROM_BANK8(0xA000,V);break; |
c62d2810 |
78 | case 0x7efe: |
d97315ac |
79 | case 0x7eff: ROM_BANK8(0xC000,V);break; |
c62d2810 |
80 | } |
81 | } |
82 | |
d97315ac |
83 | static void booga(int version) |
84 | { |
85 | mira(); |
86 | } |
87 | |
c62d2810 |
88 | void Mapper80_init(void) |
89 | { |
43725da7 |
90 | SetWriteHandler(0x4020,0x7eff,Mapper80_write);// 7f00-7fff battery backed ram inside mapper chip, |
91 | // controlled by 7ef8 register, A8 - enable, FF - disable (?) |
d97315ac |
92 | MapStateRestore=booga; |
93 | isfu=0; |
c62d2810 |
94 | } |
95 | |
d97315ac |
96 | void Mapper207_init(void) |
97 | { |
98 | Mapper80_init(); |
99 | isfu=1; |
100 | PPU_hook=Fudou_PPU; |
101 | } |