merge mapper code from FCEUX
[fceu.git] / mappers / 17.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
386f5371 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
c62d2810 19 */
20
21#include "mapinc.h"
22
23
24
386f5371 25static void FFEIRQHook(int a)
c62d2810 26{
27 if(IRQa)
28 {
29 IRQCount+=a;
c62d2810 30 if(IRQCount>=0x10000)
31 {
d97315ac 32 X6502_IRQBegin(FCEU_IQEXT);
c62d2810 33 IRQa=0;
34 IRQCount=0;
35 }
36 }
37}
38
39
40DECLFW(Mapper17_write)
41{
42 switch(A){
43 default:
d97315ac 44 break;
c62d2810 45 case 0x42FE:
46 onemir((V>>4)&1);
47 break;
48 case 0x42FF:
49 MIRROR_SET((V>>4)&1);
d97315ac 50 break;
51 case 0x4501:IRQa=0;X6502_IRQEnd(FCEU_IQEXT);break;
c62d2810 52 case 0x4502:IRQCount&=0xFF00;IRQCount|=V;break;
53 case 0x4503:IRQCount&=0x00FF;IRQCount|=V<<8;IRQa=1;break;
d97315ac 54 case 0x4504: ROM_BANK8(0x8000,V);break;
55 case 0x4505: ROM_BANK8(0xA000,V);break;
56 case 0x4506: ROM_BANK8(0xC000,V);break;
57 case 0x4507: ROM_BANK8(0xE000,V);break;
c62d2810 58 case 0x4510: VROM_BANK1(0x0000,V);break;
59 case 0x4511: VROM_BANK1(0x0400,V);break;
60 case 0x4512: VROM_BANK1(0x0800,V);break;
61 case 0x4513: VROM_BANK1(0x0C00,V);break;
62 case 0x4514: VROM_BANK1(0x1000,V);break;
63 case 0x4515: VROM_BANK1(0x1400,V);break;
64 case 0x4516: VROM_BANK1(0x1800,V);break;
65 case 0x4517: VROM_BANK1(0x1C00,V);break;
66 }
67}
68
69void Mapper17_init(void)
70{
71MapIRQHook=FFEIRQHook;
72SetWriteHandler(0x4020,0x5fff,Mapper17_write);
73}