merge mappers from FCEU-mm
[fceu.git] / mappers / 244.c
1 /* FCE Ultra - NES/Famicom Emulator
2  *
3  * Copyright notice for this file:
4  *  Copyright (C) 2011 CaH4e3
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 static uint8 prg_perm[4][4] = {
24        {0, 1, 2, 3,},
25        {3, 2, 1, 0,}, 
26        {0, 2, 1, 3,},
27        {3, 1, 2, 0,},
28 };
29
30 static uint8 chr_perm[8][8] = {
31        {0, 1, 2, 3, 4, 5, 6, 7,},
32        {0, 2, 1, 3, 4, 6, 5, 7,},
33        {0, 1, 4, 5, 2, 3, 6, 7,},
34        {0, 4, 1, 5, 2, 6, 3, 7,},
35        {0, 4, 2, 6, 1, 5, 3, 7,},
36        {0, 2, 4, 6, 1, 3, 5, 7,},
37        {7, 6, 5, 4, 3, 2, 1, 0,},
38        {7, 6, 5, 4, 3, 2, 1, 0,},
39 };
40
41 static DECLFW(Mapper244_write)
42 {
43   if(V&8)
44     VROM_BANK8(chr_perm[(V>>4)&7][V&7]);
45   else
46     ROM_BANK32(prg_perm[(V>>4)&3][V&3]);
47 }
48
49 void Mapper244_init(void)
50 {
51   ROM_BANK32(0);
52   SetWriteHandler(0x8000,0xffff,Mapper244_write);
53 }