smb3 and addams family hacks
[fceu.git] / mappers / simple.c
CommitLineData
c62d2810 1/* FCE Ultra - NES/Famicom Emulator
2 *
3 * Copyright notice for this file:
4 * Copyright (C) 1998 BERO
d97315ac 5 * Copyright (C) 2002 Xodnizel
c62d2810 6 *
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.
11 *
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.
16 *
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
20 */
d97315ac 21
c62d2810 22#include "mapinc.h"
23
24static uint8 latche;
25
d97315ac 26static DECLFW(Mapper34_write)
27{
28 switch(A)
c62d2810 29 {
d97315ac 30 case 0x7FFD:ROM_BANK32(V);break;
31 case 0x7FFE:VROM_BANK4(0x0000,V);break;
32 case 0x7fff:VROM_BANK4(0x1000,V);break;
c62d2810 33 }
c0bf6f9f 34 if(A>=0x8000)
c0bf6f9f 35 ROM_BANK32(V);
c62d2810 36}
37
38void Mapper34_init(void)
39{
d97315ac 40 ROM_BANK32(0);
c62d2810 41 SetWriteHandler(0x7ffd,0xffff,Mapper34_write);
42}
43
c62d2810 44/* I might want to add some code to the mapper 96 PPU hook function
45 to not change CHR banks if the attribute table is being accessed,
46 if I make emulation a little more accurate in the future.
47*/
48
49static uint8 M96LA;
50static DECLFW(Mapper96_write)
51{
52 latche=V;
53 setprg32(0x8000,V&3);
54 setchr4r(0x10,0x0000,(latche&4)|M96LA);
55 setchr4r(0x10,0x1000,(latche&4)|3);
56}
57
58static void FP_FASTAPASS(1) M96Hook(uint32 A)
59{
d97315ac 60 if((A&0x3000)!=0x2000) return;
61 //if((A&0x3ff)>=0x3c0) return;
c62d2810 62 M96LA=(A>>8)&3;
63 setchr4r(0x10,0x0000,(latche&4)|M96LA);
64}
65
d97315ac 66static void M96Sync(int v)
c62d2810 67{
68 setprg32(0x8000,latche&3);
69 setchr4r(0x10,0x0000,(latche&4)|M96LA);
70 setchr4r(0x10,0x1000,(latche&4)|3);
71}
72
73void Mapper96_init(void)
74{
75 SetWriteHandler(0x8000,0xffff,Mapper96_write);
76 PPU_hook=M96Hook;
77 AddExState(&latche, 1, 0, "LATC");
78 AddExState(&M96LA, 1, 0, "LAVA");
79 SetupCartCHRMapping(0x10, MapperExRAM, 32768, 1);
80 latche=M96LA=0;
d97315ac 81 M96Sync(0);
82 setmirror(MI_0);
c62d2810 83 GameStateRestore=M96Sync;
84}
85
d97315ac 86static DECLFW(M156Write)
87{
88 if(A>=0xc000 && A<=0xC003)
89 VROM_BANK1((A&3)*1024,V);
90 else if(A>=0xc008 && A<=0xc00b)
91 VROM_BANK1(0x1000+(A&3)*1024,V);
92 if(A==0xc010) ROM_BANK16(0x8000,V);
93// printf("$%04x:$%02x\n",A,V);
c62d2810 94}
d97315ac 95
96void Mapper156_init(void)
97{
98 onemir(0);
99 SetWriteHandler(0xc000,0xc010,M156Write);
100}