cleanups, savestates, input (combos), menu
[fceu.git] / mappers / 18.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 K4buf mapbyte2
24#define K4buf2 mapbyte3
25
26void FP_FASTAPASS(1) JalecoIRQHook(int a)
27{
28 if(IRQa && IRQCount)
29 {
30 IRQCount-=a;
31 if(IRQCount<=0)
32 {
33 X6502_IRQBegin(FCEU_IQEXT);
34 IRQCount=0;
35 IRQa=0;
36 }
37 }
38}
39
40DECLFW(Mapper18_write)
41{
d97315ac 42 A&=0xF003;
43 if(A>=0x8000 && A<=0x9001)
44 {
c62d2810 45 int x=((A>>1)&1)|((A-0x8000)>>11);
46
47 K4buf2[x]&=(0xF0)>>((A&1)<<2);
48 K4buf2[x]|=(V&0xF)<<((A&1)<<2);
49 ROM_BANK8(0x8000+(x<<13),K4buf2[x]);
d97315ac 50 }
51 else if(A>=0xa000 && A<=0xd003)
52 {
53 int x=((A>>1)&1)|((A-0xA000)>>11);
c62d2810 54
55 K4buf[x]&=(0xF0)>>((A&1)<<2);
56 K4buf[x]|=(V&0xF)<<((A&1)<<2);
57 VROM_BANK1(x<<10,K4buf[x]);
d97315ac 58 }
c62d2810 59 else switch(A)
60 {
d97315ac 61 case 0xe000:IRQLatch&=0xFFF0;IRQLatch|=(V&0x0f);break;
62 case 0xe001:IRQLatch&=0xFF0F;IRQLatch|=(V&0x0f)<<4;break;
63 case 0xe002:IRQLatch&=0xF0FF;IRQLatch|=(V&0x0f)<<8;break;
64 case 0xe003:IRQLatch&=0x0FFF;IRQLatch|=(V&0x0f)<<12;break;
65 case 0xf000:IRQCount=IRQLatch;
66 break;
67 case 0xf001:IRQa=V&1;
68 X6502_IRQEnd(FCEU_IQEXT);
69 break;
70 case 0xf002:MIRROR_SET2(V&1);
71 if(V&2) onemir(0);
72 break;
c62d2810 73 }
74}
75
76void Mapper18_init(void)
77{
78 SetWriteHandler(0x8000,0xffff,Mapper18_write);
79 MapIRQHook=JalecoIRQHook;
80}