1 /* FCE Ultra - NES/Famicom Emulator
3 * Copyright notice for this file:
4 * Copyright (C) 2002 Xodnizel
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]
30 static OPLL *VRC7Sound=NULL;
33 void DoVRC7Sound(void)
37 //if(FSettings.soundq>=1) return;
38 z=((SOUNDTS<<16)/soundtsinc)>>4;
41 moocow(VRC7Sound, (int32 *)&Wave[dwave], a, 1);
46 void UpdateOPLNEO(int32 *Wave, int Count)
48 moocow(VRC7Sound, Wave, Count, 4);
51 void UpdateOPL(int Count)
55 z=((SOUNDTS<<16)/soundtsinc)>>4;
59 moocow(VRC7Sound, (int32 *)&Wave[dwave], a, 1);
64 static INLINE void DaMirror(int V)
66 int salpo[4]={MI_V,MI_H,MI_0,MI_1};
67 setmirror(salpo[V&3]);
70 DECLFW(Mapper85_write)
74 if(A>=0xa000 && A<=0xDFFF)
76 // printf("$%04x, $%04x\n",X.PC,A);
79 int x=((A>>4)&1)|((A-0xA000)>>11);
88 OPLL_writeReg(VRC7Sound, indox, V);
89 GameExpSound.Fill=UpdateOPL;
90 GameExpSound.NeoFill=UpdateOPLNEO;
95 case 0x8000:mapbyte2[0]=V;setprg8(0x8000,V);break;
96 case 0x8010:mapbyte2[1]=V;setprg8(0xa000,V);break;
97 case 0x9000:mapbyte2[2]=V;setprg8(0xc000,V);break;
98 case 0x9010:indox=V;break;
99 case 0xe000:mapbyte2[3]=V;DaMirror(V);break;
100 case 0xE010:IRQLatch=V;
101 X6502_IRQEnd(FCEU_IQEXT);
103 case 0xF000:IRQa=V&2;
105 if(V&2) {IRQCount=IRQLatch;}
107 X6502_IRQEnd(FCEU_IQEXT);
109 case 0xf010:if(vrctemp) IRQa=1;
111 X6502_IRQEnd(FCEU_IQEXT);
116 static void FP_FASTAPASS(1) KonamiIRQHook(int a)
119 // #define ACBOO ((227*2)+1)
126 doagainbub:acount-=ACBOO;
128 if(IRQCount&0x100) {X6502_IRQBegin(FCEU_IQEXT);IRQCount=IRQLatch;}
129 if(acount>=ACBOO) goto doagainbub;
134 void Mapper85_StateRestore(int version)
141 mapbyte3[x]=CHRBankList[x];
143 mapbyte2[x]=PRGBankList[x];
144 mapbyte2[3]=(Mirroring<0x10)?Mirroring:Mirroring-0xE;
148 setchr1(x*0x400,mapbyte3[x]);
150 setprg8(0x8000+x*8192,mapbyte2[x]);
151 DaMirror(mapbyte2[3]);
155 static void M85SC(void)
158 OPLL_set_rate(VRC7Sound, FSettings.SndRate);
161 static void M85SKill(void)
164 OPLL_delete(VRC7Sound);
168 static void VRC7SI(void)
170 GameExpSound.RChange=M85SC;
171 GameExpSound.Kill=M85SKill;
173 VRC7Sound=OPLL_new(3579545, FSettings.SndRate?FSettings.SndRate:44100);
174 OPLL_reset(VRC7Sound);
175 OPLL_reset(VRC7Sound);
178 void NSFVRC7_Init(void)
180 SetWriteHandler(0x9010,0x901F,Mapper85_write);
181 SetWriteHandler(0x9030,0x903F,Mapper85_write);
185 void Mapper85_init(void)
187 MapIRQHook=KonamiIRQHook;
188 SetWriteHandler(0x8000,0xffff,Mapper85_write);
189 GameStateRestore=Mapper85_StateRestore;
191 SetupCartCHRMapping(0, CHRRAM, 8192, 1);
192 //AddExState(VRC7Instrument, 16, 0, "VC7I");
193 //AddExState(VRC7Chan, sizeof(VRC7Chan), 0, "V7CH");