updated bords/mappers/stuff to 0.98.15, lots of them got broken, asmcore support...
[fceu.git] / mappers / 51.c
CommitLineData
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#define mode mapbyte1[0]
24#define page mapbyte1[1]
25
26static uint32 Get8K(uint32 A)
27{
28 uint32 bank;
d97315ac 29
c62d2810 30 bank=(page<<2)|((A>>13)&1);
31
32 if(A&0x4000 && !(mode&1)) bank|=0xC;
33 if(!(A&0x8000)) bank|=0x20;
34 if(mode==2) bank|=2;
35 else bank|=(A>>13)&2;
36 return(bank);
37}
38
39static void Synco(void)
40{
41 uint32 x;
42 if(mapbyte1[0]<=2)
43 MIRROR_SET2(1);
44 else
45 MIRROR_SET2(0);
46 for(x=0x6000;x<0x10000;x+=8192)
47 ROM_BANK8(x,Get8K(x));
48}
49
50static DECLFW(Write)
51{
52 if(A&0x8000) mapbyte1[1]=V&0xF;
53 else mapbyte1[0]=(mapbyte1[0]&2)|((V>>1)&1);
54
55 if(A&0x4000) mapbyte1[0]=(mapbyte1[0]&1)|((V>>3)&2);
56 Synco();
57}
58
59void Mapper51_init(void)
60{
61 SetWriteHandler(0x6000,0xFFFF,Write);
62 SetReadHandler(0x6000,0xFFFF,CartBR);
63 mapbyte1[0]=1;
64 mapbyte1[1]=0;
65 Synco();
66}