1 /* FCE Ultra - NES/Famicom Emulator
3 * Copyright notice for this file:
4 * Copyright (C) 2002 Xodnizel
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 //16 bits of ram in total
24 //only use bottom 4 bits as ram though
25 static uint8 mapper228_ram[4];
27 static SFORMAT StateRegs[]=
29 { mapper228_ram, 4, "MAPPER_RAM" },
33 static DECLFR(Mapper228_read)
35 return mapper228_ram[A & 3] & 0xF;
38 static DECLFW(Mapper228_write)
40 uint32 page, pagel, pageh;
45 mapper228_ram[A & 3] = V;
48 MIRROR_SET((A >> 13) & 1);
49 page = (A >> 7) & 0x3F;
51 if( (page & 0x30) == 0x30)
54 pagel = pageh = (page << 1) + (((A >> 6) & 1) & ((A >> 5) & 1));
55 pageh += ((A >> 5) & 1) ^ 1;
57 ROM_BANK16(0x8000,pagel);
58 ROM_BANK16(0xC000,pageh);
59 VROM_BANK8( (V&0x3) | ((A&0xF)<<2) );
62 static void A52Reset(void)
64 Mapper228_write(0x8000, 0);
67 void Mapper228_init(void)
71 SetWriteHandler(0x8000, 0xFFFF, Mapper228_write);
72 SetWriteHandler(0x4020, 0x5FFF, Mapper228_write);
73 SetReadHandler (0x4020, 0x5FFF, Mapper228_read);
74 AddExState(StateRegs, ~0, 0, 0);