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
26 #define vrctemp mapbyte1[0]
33 static OPLL *VRC7Sound=NULL;
36 void DoVRC7Sound(void)
40 if(FSettings.soundq>=1) return;
41 z=((SOUNDTS<<16)/soundtsinc)>>4;
44 moocow(VRC7Sound, &Wave[dwave], a, 1);
49 void UpdateOPLNEO(int32 *Wave, int Count)
51 moocow(VRC7Sound, Wave, Count, 4);
54 void UpdateOPL(int Count)
58 z=((SOUNDTS<<16)/soundtsinc)>>4;
62 moocow(VRC7Sound, &Wave[dwave], a, 1);
67 static INLINE void DaMirror(int V)
69 int salpo[4]={MI_V,MI_H,MI_0,MI_1};
70 setmirror(salpo[V&3]);
73 DECLFW(Mapper85_write)
77 if(A>=0xa000 && A<=0xDFFF)
79 // printf("$%04x, $%04x\n",X.PC,A);
82 int x=((A>>4)&1)|((A-0xA000)>>11);
91 OPLL_writeReg(VRC7Sound, indox, V);
92 GameExpSound.Fill=UpdateOPL;
93 GameExpSound.NeoFill=UpdateOPLNEO;
98 case 0x8000:mapbyte2[0]=V;setprg8(0x8000,V);break;
99 case 0x8010:mapbyte2[1]=V;setprg8(0xa000,V);break;
100 case 0x9000:mapbyte2[2]=V;setprg8(0xc000,V);break;
101 case 0x9010:indox=V;break;
102 case 0xe000:mapbyte2[3]=V;DaMirror(V);break;
103 case 0xE010:IRQLatch=V;
104 X6502_IRQEnd(FCEU_IQEXT);
106 case 0xF000:IRQa=V&2;
108 if(V&2) {IRQCount=IRQLatch;}
110 X6502_IRQEnd(FCEU_IQEXT);
112 case 0xf010:if(vrctemp) IRQa=1;
114 X6502_IRQEnd(FCEU_IQEXT);
119 static void FP_FASTAPASS(1) KonamiIRQHook(int a)
122 // #define ACBOO ((227*2)+1)
129 doagainbub:acount-=ACBOO;
131 if(IRQCount&0x100) {X6502_IRQBegin(FCEU_IQEXT);IRQCount=IRQLatch;}
132 if(acount>=ACBOO) goto doagainbub;
137 void Mapper85_StateRestore(int version)
144 mapbyte3[x]=CHRBankList[x];
146 mapbyte2[x]=PRGBankList[x];
147 mapbyte2[3]=(Mirroring<0x10)?Mirroring:Mirroring-0xE;
151 setchr1(x*0x400,mapbyte3[x]);
153 setprg8(0x8000+x*8192,mapbyte2[x]);
154 DaMirror(mapbyte2[3]);
158 static void M85SC(void)
161 OPLL_set_rate(VRC7Sound, FSettings.SndRate);
164 static void M85SKill(void)
167 OPLL_delete(VRC7Sound);
171 static void VRC7SI(void)
173 GameExpSound.RChange=M85SC;
174 GameExpSound.Kill=M85SKill;
176 VRC7Sound=OPLL_new(3579545, FSettings.SndRate?FSettings.SndRate:44100);
177 OPLL_reset(VRC7Sound);
178 OPLL_reset(VRC7Sound);
181 void NSFVRC7_Init(void)
183 SetWriteHandler(0x9010,0x901F,Mapper85_write);
184 SetWriteHandler(0x9030,0x903F,Mapper85_write);
188 void Mapper85_init(void)
190 MapIRQHook=KonamiIRQHook;
191 SetWriteHandler(0x8000,0xffff,Mapper85_write);
192 GameStateRestore=Mapper85_StateRestore;
194 SetupCartCHRMapping(0, CHRRAM, 8192, 1);
195 //AddExState(VRC7Instrument, 16, 0, "VC7I");
196 //AddExState(VRC7Chan, sizeof(VRC7Chan), 0, "V7CH");