updated bords/mappers/stuff to 0.98.15, lots of them got broken, asmcore support...
[fceu.git] / mappers / 82.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
d97315ac 23#define ctrl mapbyte1[6]
c62d2810 24
25static void DoCHR(void)
26{
27 int x;
28
29 for(x=0;x<2;x++)
30 VROM_BANK2((x<<11)|((ctrl&2)<<11),mapbyte1[x]>>1);
31 for(x=0;x<4;x++)
32 VROM_BANK1((x<<10) | (((ctrl&2)^2)<<11),mapbyte1[2+x]);
33}
34
35static DECLFW(Mapper82_write)
36{
37 if(A<=0x7EF5)
38 {
39 mapbyte1[A&7]=V;
40 DoCHR();
41 }
42 else
43 switch(A)
44 {
45 case 0x7ef6:ctrl=V&3;
d97315ac 46 MIRROR_SET2(V&1);
47 DoCHR();
48 break;
49 case 0x7efa:V>>=2;mapbyte2[0]=V;ROM_BANK8(0x8000,V);break;
50 case 0x7efb:V>>=2;mapbyte2[1]=V;ROM_BANK8(0xa000,V);break;
51 case 0x7efc:V>>=2;mapbyte2[2]=V;ROM_BANK8(0xc000,V);break;
c62d2810 52 }
53}
54
55void Mapper82_init(void)
56{
57 ROM_BANK8(0xE000,~0);
58
59 /* external WRAM might end at $73FF */
60 SetWriteHandler(0x7ef0,0x7efc,Mapper82_write);
61}
62