initial fce ultra 0.81 import
[fceu.git] / mappers / 225.c
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
24 #define reg1 mapbyte1[0]
25 #define reg2 mapbyte1[1]
26 #define reg3 mapbyte1[2]
27 #define reg4 mapbyte1[3]
28
29 DECLFR(A110in1read)
30 {
31 switch(A&0x3)
32  {
33   case 0:return reg1;break;
34   case 1:return reg2;break;
35   case 2:return reg3;break;
36   case 3:return reg4;break;
37  }
38 return 0xF;
39 }
40 DECLFW(A110in1regwr)
41 {
42 switch(A&0x3)
43  {
44   case 0:reg1=V&0xF;break;
45   case 1:reg2=V&0xF;break;
46   case 2:reg3=V&0xF;break;
47   case 3:reg4=V&0xF;break;
48  }
49 }
50
51 DECLFW(Mapper225_write)
52 {
53  int banks=0;
54
55  MIRROR_SET((A>>13)&1);
56  if(A&0x4000)
57   banks=1;
58  else
59   banks=0;
60
61   VROM_BANK8(((A&0x003f)+(banks<<6)));
62  if(A&0x1000)
63   {
64    if(A&0x40)
65     {
66      ROM_BANK16(0x8000,((((((A>>7)&0x1F)+(banks<<5)))<<1)+1));
67      ROM_BANK16(0xC000,((((((A>>7)&0x1F)+(banks<<5)))<<1)+1));
68     }
69     else
70     {
71      ROM_BANK16(0x8000,(((((A>>7)&0x1F)+(banks<<5)))<<1));
72      ROM_BANK16(0xC000,(((((A>>7)&0x1F)+(banks<<5)))<<1));
73     }
74   }
75   else
76   {
77     ROM_BANK32(((((A>>7)&0x1F)+(banks<<5))));
78   }
79 }
80
81 void Mapper225_init(void)
82 {
83   SetWriteHandler(0x8000,0xffff,Mapper225_write);
84   SetReadHandler(0x5800,0x5fff,A110in1read);
85   SetWriteHandler(0x5800,0x5fff,A110in1regwr);
86 }
87