X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=fceu.git;a=blobdiff_plain;f=boards%2F117.c;fp=boards%2F117.c;h=67460151d16c3dd5bb561ffe7ff5498cb78fec93;hp=0000000000000000000000000000000000000000;hb=e2d0dd92bfad989cce4270fc0ac5a712476c7c50;hpb=971a1d07d2f5b5a6f991ed5712275c04b933734f diff --git a/boards/117.c b/boards/117.c new file mode 100644 index 0000000..6746015 --- /dev/null +++ b/boards/117.c @@ -0,0 +1,101 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2002 Xodnizel + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "mapinc.h" + +static uint8 prgreg[4], chrreg[8]; +static uint8 IRQa, IRQCount, IRQLatch; + +static SFORMAT StateRegs[]= +{ + {&IRQa, 1, "IRQA"}, + {&IRQCount, 1, "IRQC"}, + {&IRQLatch, 1, "IRQL"}, + {prgreg, 4, "PREGS"}, + {chrreg, 8, "CREGS"}, + {0} +}; + +static void Sync(void) +{ + setprg8(0x8000,prgreg[0]); + setprg8(0xa000,prgreg[1]); + setprg8(0xc000,prgreg[2]); + setprg8(0xe000,prgreg[3]); + int i; + for(i=0; i<8; i++) + setchr1(i<<10,chrreg[i]); +} + +static DECLFW(M117Write) +{ + if(A<0x8004) + { + prgreg[A&3]=V; + Sync(); + } + else if((A>=0xA000)&&(A<=0xA007)) + { + chrreg[A&7]=V; + Sync(); + } + else switch(A) + { + case 0xc001: IRQLatch=V; break; + case 0xc003: IRQCount=IRQLatch; IRQa|=2; break; + case 0xe000: IRQa&=~1; IRQa|=V&1; X6502_IRQEnd(FCEU_IQEXT); break; + case 0xc002: X6502_IRQEnd(FCEU_IQEXT); break; + } +} + +static void M117Power(void) +{ + prgreg[0]=~3; prgreg[1]=~2; prgreg[2]=~1; prgreg[3]=~0; + Sync(); + SetReadHandler(0x8000,0xFFFF,CartBR); + SetWriteHandler(0x8000,0xFFFF,M117Write); +} + +static void M117IRQHook(void) +{ + if(IRQa==3&&IRQCount) + { + IRQCount--; + if(!IRQCount) + { + IRQa&=1; + X6502_IRQBegin(FCEU_IQEXT); + } + } +} + +static void StateRestore(int version) +{ + Sync(); +} + +void Mapper117_Init(CartInfo *info) +{ + info->Power=M117Power; + GameHBIRQHook=M117IRQHook; + GameStateRestore=StateRestore; + AddExState(&StateRegs, ~0, 0, 0); +} +