| 1 | /* FCE Ultra - NES/Famicom Emulator |
| 2 | * |
| 3 | * Copyright notice for this file: |
| 4 | * Copyright (C) 2002 Ben Parnell |
| 5 | * |
| 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. |
| 10 | * |
| 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. |
| 15 | * |
| 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 |
| 19 | */ |
| 20 | |
| 21 | #include "mapinc.h" |
| 22 | |
| 23 | |
| 24 | #define FVRAM_BANK8(A,V) {VPage[0]=VPage[1]=VPage[2]=VPage[3]=VPage[4]=VPage[5]=VPage[6]=VPage[7]=V?&MapperExRAM[(V)<<13]-(A):&CHRRAM[(V)<<13]-(A);CHRBankList[0]=((V)<<3);CHRBankList[1]=((V)<<3)+1;CHRBankList[2]=((V)<<3)+2;CHRBankList[3]=((V)<<3)+3;CHRBankList[4]=((V)<<3)+4;CHRBankList[5]=((V)<<3)+5;CHRBankList[6]=((V)<<3)+6;CHRBankList[7]=((V)<<3)+7;PPUCHRRAM=0xFF;} |
| 25 | |
| 26 | static void FP_FASTAPASS(1) FFEIRQHook(int a) |
| 27 | { |
| 28 | if(IRQa) |
| 29 | { |
| 30 | IRQCount+=a; |
| 31 | if(IRQCount>=0x10000) |
| 32 | { |
| 33 | TriggerIRQ(); |
| 34 | IRQa=0; |
| 35 | IRQCount=0; |
| 36 | } |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | DECLFW(Mapper6_write) |
| 41 | { |
| 42 | if(A<0x8000) |
| 43 | { |
| 44 | switch(A){ |
| 45 | case 0x42FF:MIRROR_SET((V>>4)&1);break; |
| 46 | case 0x42FE:onemir((V>>3)&2);break; |
| 47 | case 0x4501:IRQa=0;break; |
| 48 | case 0x4502:IRQCount&=0xFF00;IRQCount|=V;break; |
| 49 | case 0x4503:IRQCount&=0xFF;IRQCount|=V<<8;IRQa=1;break; |
| 50 | } |
| 51 | } else { |
| 52 | ROM_BANK16(0x8000,V>>2); |
| 53 | FVRAM_BANK8(0x0000,V&3); |
| 54 | } |
| 55 | } |
| 56 | void Mapper6_StateRestore(int version) |
| 57 | { |
| 58 | int x; |
| 59 | for(x=0;x<8;x++) |
| 60 | if(PPUCHRRAM&(1<<x)) |
| 61 | { |
| 62 | if(CHRBankList[x]>7) |
| 63 | VPage[x]=&MapperExRAM[(CHRBankList[x]&31)*0x400]-(x*0x400); |
| 64 | else VPage[x]=&CHRRAM[(CHRBankList[x]&7)*0x400]-(x*0x400); |
| 65 | } |
| 66 | } |
| 67 | void Mapper6_init(void) |
| 68 | { |
| 69 | MapIRQHook=FFEIRQHook; |
| 70 | ROM_BANK16(0xc000,7); |
| 71 | |
| 72 | SetWriteHandler(0x4020,0x5fff,Mapper6_write); |
| 73 | SetWriteHandler(0x8000,0xffff,Mapper6_write); |
| 74 | MapStateRestore=Mapper6_StateRestore; |
| 75 | } |
| 76 | |