1 /* FCE Ultra - NES/Famicom Emulator
3 * Copyright notice for this file:
4 * Copyright (C) 1998 BERO
5 * Copyright (C) 2002 Xodnizel
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 //static DECLFW(Mapper2_write)
29 // ROM_BANK16(0x8000,V);
32 //void Mapper2_init(void)
34 // SetWriteHandler(0x8000,0xFFFF,Mapper2_write);
35 // AddExState(&latche, 1, 0, "LATC");
38 //static DECLFW(Mapper3_write)
44 //void Mapper3_init(void)
46 // SetWriteHandler(0x8000,0xFFFF,Mapper3_write);
47 // AddExState(&latche, 1, 0, "LATC");
50 static DECLFW(Mapper7_write)
52 // FCEU_printf("%04x,%04x\n",A,V);
58 void Mapper7_init(void)
62 SetWriteHandler(0x8000,0xFFFF,Mapper7_write);
63 AddExState(&latche, 1, 0, "LATC");
66 static DECLFW(Mapper11_write)
73 void Mapper11_init(void)
76 SetWriteHandler(0x8000,0xFFFF,Mapper11_write);
77 AddExState(&latche, 1, 0, "LATC");
79 void Mapper144_init(void)
82 SetWriteHandler(0x8001,0xFFFF,Mapper11_write);
83 AddExState(&latche, 1, 0, "LATC");
86 //static DECLFW(Mapper13_write)
88 // setchr4r(0x10,0x1000,V&3);
89 // setprg32(0x8000,(V>>4)&3);
93 //static void Mapper13_StateRestore(int version)
95 // setchr4r(0x10,0x0000,0);
96 // setchr4r(0x10,0x1000,latche&3);
97 // setprg32(0x8000,(latche>>4)&3);
100 //void Mapper13_init(void)
102 // SetWriteHandler(0x8000,0xFFFF,Mapper13_write);
103 // GameStateRestore=Mapper13_StateRestore;
104 // AddExState(&latche, 1, 0, "LATC");
105 // AddExState(MapperExRAM, 16384, 0, "CHRR");
106 // SetupCartCHRMapping(0x10, MapperExRAM, 16384, 1);
108 // Mapper13_StateRestore(FCEU_VERSION_NUMERIC);
111 static DECLFW(Mapper34_write)
115 case 0x7FFD:ROM_BANK32(V);break;
116 case 0x7FFE:VROM_BANK4(0x0000,V);break;
117 case 0x7fff:VROM_BANK4(0x1000,V);break;
123 void Mapper34_init(void)
126 SetWriteHandler(0x7ffd,0xffff,Mapper34_write);
129 DECLFW(Mapper66_write)
136 void Mapper66_init(void)
139 SetWriteHandler(0x6000,0xffff,Mapper66_write);
140 AddExState(&latche, 1, 0, "LATC");
143 DECLFW(Mapper152_write)
145 ROM_BANK16(0x8000,(V>>4)&0x7);
147 onemir((V>>7)&1); /* Saint Seiya...hmm. */
151 void Mapper152_init(void)
154 SetWriteHandler(0x6000,0xffff,Mapper152_write);
155 AddExState(&latche, 1, 0, "LATC");
158 static DECLFW(Mapper70_write)
160 ROM_BANK16(0x8000,V>>4);
165 void Mapper70_init(void)
167 SetWriteHandler(0x6000,0xffff,Mapper70_write);
168 AddExState(&latche, 1, 0, "LATC");
170 /* Should be two separate emulation functions for this "mapper". Sigh. URGE TO KILL RISING. */
171 static DECLFW(Mapper78_write)
173 //printf("$%04x:$%02x\n",A,V&0x8);
174 ROM_BANK16(0x8000,V&0x7);
180 void Mapper78_init(void)
182 SetWriteHandler(0x8000,0xffff,Mapper78_write);
183 AddExState(&latche, 1, 0, "LATC");
186 DECLFW(Mapper87_write)
192 void Mapper87_init(void)
194 SetWriteHandler(0x6000,0xffff,Mapper87_write);
195 AddExState(&latche, 1, 0, "LATC");
198 DECLFW(Mapper93_write)
200 ROM_BANK16(0x8000,V>>4);
205 void Mapper93_init(void)
207 SetWriteHandler(0x8000,0xffff,Mapper93_write);
208 AddExState(&latche, 1, 0, "LATC");
212 DECLFW(Mapper94_write)
214 ROM_BANK16(0x8000,V>>2);
218 void Mapper94_init(void)
220 SetWriteHandler(0x8000,0xffff,Mapper94_write);
221 AddExState(&latche, 1, 0, "LATC");
224 /* I might want to add some code to the mapper 96 PPU hook function
225 to not change CHR banks if the attribute table is being accessed,
226 if I make emulation a little more accurate in the future.
230 static DECLFW(Mapper96_write)
233 setprg32(0x8000,V&3);
234 setchr4r(0x10,0x0000,(latche&4)|M96LA);
235 setchr4r(0x10,0x1000,(latche&4)|3);
238 static void FP_FASTAPASS(1) M96Hook(uint32 A)
240 if((A&0x3000)!=0x2000) return;
241 //if((A&0x3ff)>=0x3c0) return;
243 setchr4r(0x10,0x0000,(latche&4)|M96LA);
246 static void M96Sync(int v)
248 setprg32(0x8000,latche&3);
249 setchr4r(0x10,0x0000,(latche&4)|M96LA);
250 setchr4r(0x10,0x1000,(latche&4)|3);
253 void Mapper96_init(void)
255 SetWriteHandler(0x8000,0xffff,Mapper96_write);
257 AddExState(&latche, 1, 0, "LATC");
258 AddExState(&M96LA, 1, 0, "LAVA");
259 SetupCartCHRMapping(0x10, MapperExRAM, 32768, 1);
263 GameStateRestore=M96Sync;
266 static DECLFW(Mapper140_write)
269 ROM_BANK32((V>>4)&0xF);
272 void Mapper140_init(void)
275 SetWriteHandler(0x6000,0x7FFF,Mapper140_write);
278 static void M185Sync(int version)
281 //1 0x0F, 0xF0 - Bird Week
282 //2 0x33, 0x00 - B-Wings
283 //3 0x11, 0x00 - Mighty Bomb Jack
284 //4 0x22, 0x20 - Sansuu 1 Nen, Sansuu 2 Nen
285 //5 0xFF, 0x00 - Sansuu 3 Nen
286 //6 0x21, 0x13 - Spy vs Spy
288 // if((mapbyte1[0]&3)==1) // 6, 3
289 // if(mapbyte1[0]&1) // 1, 2, 3, 5
290 // if(mapbyte1[0]&2) // 1, 2, 4, 5,
291 if((mapbyte1[0]&2)||((mapbyte1[0]&3)==1)) // 1, 2, 3, 4, 5
297 static DECLFW(Mapper185_write)
303 void Mapper185_init(void)
308 MapStateRestore=M185Sync;
311 SetupCartCHRMapping(0x10,MapperExRAM,8192,0);
312 SetWriteHandler(0x8000,0xFFFF,Mapper185_write);
316 static DECLFW(M156Write)
318 if(A>=0xc000 && A<=0xC003)
319 VROM_BANK1((A&3)*1024,V);
320 else if(A>=0xc008 && A<=0xc00b)
321 VROM_BANK1(0x1000+(A&3)*1024,V);
322 if(A==0xc010) ROM_BANK16(0x8000,V);
323 // printf("$%04x:$%02x\n",A,V);
326 void Mapper156_init(void)
329 SetWriteHandler(0xc000,0xc010,M156Write);
334 ROM_BANK32((V>>1)&0x3);
338 void Mapper107_init(void)
340 SetWriteHandler(0x8000,0xffff,m107w);