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);break;
63 case 0x8010:mapbyte2[1]=V;setprg8(0xa000,V);break;
64 case 0x9000:mapbyte2[2]=V;setprg8(0xc000,V);break;
65 case 0x9010:indox=V;break;
66 case 0xe000:mapbyte2[3]=V;DaMirror(V);break;
67 case 0xE010:IRQLatch=V;
71 if(V&2) {IRQCount=IRQLatch;acount=0;}
73 case 0xf010:if(vrctemp) IRQa=1;
79 static void FP_FASTAPASS(1) KonamiIRQHook(int a)
86 doagainbub:acount-=339;IRQCount++;
87 if(IRQCount&0x100) {TriggerIRQ();IRQCount=IRQLatch;}
88 if(acount>=339) goto doagainbub;
93 void Mapper85_StateRestore(int version)
100 mapbyte3[x]=CHRBankList[x];
102 mapbyte2[x]=PRGBankList[x];
103 mapbyte2[3]=(Mirroring<0x10)?Mirroring:Mirroring-0xE;
107 setchr1(x*0x400,mapbyte3[x]);
109 setprg8(0x8000+x*8192,mapbyte2[x]);
110 DaMirror(mapbyte2[3]);
114 static void M85SC(void)
121 if(FSettings.SndRate)
123 SetWriteHandler(0x9010,0x901F,Mapper85_write);
124 SetWriteHandler(0x9030,0x903F,Mapper85_write);
126 GameExpSound.RChange=M85SC;
129 void Mapper85_init(void)
131 MapIRQHook=KonamiIRQHook;
132 SetWriteHandler(0x8000,0xffff,Mapper85_write);
133 GameStateRestore=Mapper85_StateRestore;
136 SetupCartCHRMapping(0, CHRRAM, 8192, 1);
137 AddExState(VRC7Instrument, 16, 0, "VC7I");
138 AddExState(VRC7Chan, sizeof(VRC7Chan), 0, "V7CH");