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 |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | */ |
20 | |
21 | #include "mapinc.h" |
22 | |
23 | static void Fixerit(void) |
24 | { |
25 | switch(mapbyte2[0]&3) |
26 | { |
d97315ac |
27 | case 0:vnapage[0]=vnapage[2]=CHRptr[0]+(((mapbyte1[0]|128)&CHRmask1[0])<<10); |
28 | vnapage[1]=vnapage[3]=CHRptr[0]+(((mapbyte1[1]|128)&CHRmask1[0])<<10); |
29 | break; |
30 | case 1:vnapage[0]=vnapage[1]=CHRptr[0]+(((mapbyte1[0]|128)&CHRmask1[0])<<10); |
31 | vnapage[2]=vnapage[3]=CHRptr[0]+(((mapbyte1[1]|128)&CHRmask1[0])<<10); |
32 | break; |
33 | case 2:vnapage[0]=vnapage[1]=vnapage[2]=vnapage[3]=CHRptr[0]+(((mapbyte1[0]|128)&CHRmask1[0])<<10); |
34 | break; |
35 | case 3:vnapage[0]=vnapage[1]=vnapage[2]=vnapage[3]=CHRptr[0]+(((mapbyte1[1]|128)&CHRmask1[0])<<10); |
c62d2810 |
36 | break; |
c62d2810 |
37 | } |
38 | } |
39 | |
40 | DECLFW(Mapper68_write) |
41 | { |
e2d0dd92 |
42 | // FCEU_printf("%04x,%04x\n",A,V); |
c62d2810 |
43 | A&=0xF000; |
44 | |
45 | if(A>=0x8000 && A<=0xB000) |
46 | { |
47 | VROM_BANK2((A-0x8000)>>1,V); |
48 | } |
49 | else switch(A) |
50 | { |
51 | case 0xc000:mapbyte1[0]=V; |
52 | if(VROM_size && mapbyte2[0]&0x10) |
d97315ac |
53 | Fixerit(); |
c62d2810 |
54 | break; |
55 | |
56 | case 0xd000:mapbyte1[1]=V; |
d97315ac |
57 | if(VROM_size && mapbyte2[0]&0x10) |
58 | Fixerit(); |
c62d2810 |
59 | break; |
60 | |
61 | case 0xe000: mapbyte2[0]=V; |
62 | if(!(V&0x10)) |
63 | { |
64 | switch(V&3) |
65 | { |
66 | case 0:MIRROR_SET2(1);break; |
67 | case 1:MIRROR_SET2(0);break; |
68 | case 2:onemir(0);break; |
69 | case 3:onemir(1);break; |
70 | } |
71 | } |
72 | else if(VROM_size) |
d97315ac |
73 | { |
74 | Fixerit(); |
75 | PPUNTARAM=0; |
76 | } |
c62d2810 |
77 | break; |
d97315ac |
78 | case 0xf000: ROM_BANK16(0x8000,V);break; |
c62d2810 |
79 | } |
80 | } |
81 | |
82 | static void Mapper68_StateRestore(int version) |
83 | { |
84 | if(!(mapbyte2[0]&0x10)) |
85 | { |
86 | switch(mapbyte2[0]&3) |
87 | { |
88 | case 0:MIRROR_SET(0);break; |
89 | case 1:MIRROR_SET(1);break; |
90 | case 2:onemir(0);break; |
91 | case 3:onemir(1);break; |
92 | } |
93 | } |
94 | else if(VROM_size) |
95 | { |
d97315ac |
96 | Fixerit(); |
c62d2810 |
97 | PPUNTARAM=0; |
98 | } |
99 | } |
100 | |
101 | void Mapper68_init(void) |
102 | { |
103 | SetWriteHandler(0x8000,0xffff,Mapper68_write); |
104 | MapStateRestore=Mapper68_StateRestore; |
105 | } |