1 /* FCE Ultra - NES/Famicom Emulator
3 * Copyright notice for this file:
4 * Copyright (C) 1998 BERO
5 * Copyright (C) 2002 Ben Parnell
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #define MMC1_reg mapbyte1
25 #define MMC1_buf mapbyte2[0]
26 #define MMC1_sft mapbyte3[0]
27 #define lastn mapbyte2[1]
31 static void FP_FASTAPASS(1) NWCIRQHook(int a)
33 if(!(MMC1_reg[1]&0x10))
36 if((IRQCount|(NWCDIP<<25))>=0x3e000000)
39 X6502_IRQBegin(FCEU_IQEXT);
45 static void MMC1PRG(void)
49 switch(MMC1_reg[0]&0xC)
51 case 0xC: ROM_BANK16(0x8000,8+(MMC1_reg[3]&7));
52 ROM_BANK16(0xC000,15);
54 case 0x8: ROM_BANK16(0xC000,8+((MMC1_reg[3])&7));
59 ROM_BANK16(0x8000,8+(MMC1_reg[3]&6));
60 ROM_BANK16(0xc000,8+((MMC1_reg[3]&6)+1));
66 ROM_BANK32((MMC1_reg[1]>>1)&3);
71 DECLFW(Mapper105_write)
87 //MMC1_reg[n]&=~((1)<<(MMC1_sft));
88 MMC1_buf|=(V&1)<<(MMC1_sft++);
95 MMC1_reg[n]=V=MMC1_buf;
96 MMC1_sft = MMC1_buf=0;
100 switch(MMC1_reg[0]&3)
102 case 2: MIRROR_SET(0);break;
103 case 3: MIRROR_SET(1);break;
104 case 0: onemir(0);break;
105 case 1: onemir(1);break;
111 {IRQCount=0;X6502_IRQEnd(FCEU_IQEXT);}
122 void Mapper105_init(void)
125 for(i=0;i<4;i++) MMC1_reg[i]=0;
126 MMC1_sft = MMC1_buf =0;
129 SetWriteHandler(0x8000,0xFFFF,Mapper105_write);
130 MapIRQHook=NWCIRQHook;