1 /* FCE Ultra - NES/Famicom Emulator
3 * Copyright notice for this file:
4 * Copyright (C) 2002 Ben Parnell
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.
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.
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
23 #define vrctemp mapbyte1[0]
24 #define indox mapbyte1[1]
29 void UpdateOPL(int Count);
30 void vrc7translate(uint8 A, uint8 V);
32 extern uint8 VRC7Instrument[16][8];
33 extern uint8 VRC7Chan[3][6];
35 static INLINE void DaMirror(int V)
37 int salpo[4]={MI_V,MI_H,MI_0,MI_1};
38 setmirror(salpo[V&3]);
41 DECLFW(Mapper85_write)
45 if(A>=0xa000 && A<=0xDFFF)
49 int x=((A>>4)&1)|((A-0xA000)>>11);
57 vrc7translate(indox,V);
58 GameExpSound.Fill=UpdateOPL;
62 case 0x8000:mapbyte2[0]=V;setprg8(0x8000,V);
64 case 0x8010:mapbyte2[1]=V;setprg8(0xa000,V);
66 case 0x9000:mapbyte2[2]=V;setprg8(0xc000,V);
68 case 0x9010:indox=V;break;
69 case 0xe000:mapbyte2[3]=V;DaMirror(V);break;
70 case 0xE010:IRQLatch=V;
74 if(V&2) {IRQCount=IRQLatch;acount=0;}
76 case 0xf010:if(vrctemp) IRQa=1;
82 static void FP_FASTAPASS(1) KonamiIRQHook(int a)
89 doagainbub:acount-=339;IRQCount++;
90 if(IRQCount&0x100) {TriggerIRQ();IRQCount=IRQLatch;}
91 if(acount>=339) goto doagainbub;
96 void Mapper85_StateRestore(int version)
103 mapbyte3[x]=CHRBankList[x];
105 mapbyte2[x]=PRGBankList[x];
106 mapbyte2[3]=(Mirroring<0x10)?Mirroring:Mirroring-0xE;
110 setchr1(x*0x400,mapbyte3[x]);
112 setprg8(0x8000+x*8192,mapbyte2[x]);
113 DaMirror(mapbyte2[3]);
117 static void M85SC(void)
124 if(FSettings.SndRate)
126 SetWriteHandler(0x9010,0x901F,Mapper85_write);
127 SetWriteHandler(0x9030,0x903F,Mapper85_write);
129 GameExpSound.RChange=M85SC;
132 void Mapper85_init(void)
134 MapIRQHook=KonamiIRQHook;
135 SetWriteHandler(0x8000,0xffff,Mapper85_write);
136 GameStateRestore=Mapper85_StateRestore;
139 SetupCartCHRMapping(0, CHRRAM, 8192, 1);
140 AddExState(VRC7Instrument, 16, 0, "VC7I");
141 AddExState(VRC7Chan, sizeof(VRC7Chan), 0, "V7CH");