X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=fceu.git;a=blobdiff_plain;f=boards%2F91.c;fp=boards%2F91.c;h=0fed9df6602fd75d39c012be22d5642038b3e928;hp=0000000000000000000000000000000000000000;hb=43725da7349c85fa13e828fdbf20cc7ac8d298d6;hpb=386f5371eb984fb9c2860c83e740890a75cd45c1 diff --git a/boards/91.c b/boards/91.c new file mode 100644 index 0000000..0fed9df --- /dev/null +++ b/boards/91.c @@ -0,0 +1,95 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2012 CaH4e3 + * + * 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 cregs[4], pregs[2]; +static uint8 IRQCount, IRQa; + +static SFORMAT StateRegs[]= +{ + {cregs, 4, "CREG"}, + {pregs, 2, "PREG"}, + {&IRQa, 1, "IRQA"}, + {&IRQCount, 1, "IRQC"}, + {0} +}; + +static void Sync(void) +{ + setprg8(0x8000,pregs[0]); + setprg8(0xa000,pregs[1]); + setprg8(0xc000,~1); + setprg8(0xe000,~0); + setchr2(0x0000,cregs[0]); + setchr2(0x0800,cregs[1]); + setchr2(0x1000,cregs[2]); + setchr2(0x1800,cregs[3]); +} + +static DECLFW(M91Write0) +{ + cregs[A & 3] = V; + Sync(); +} + +static DECLFW(M91Write1) +{ + switch (A & 3) + { + case 0: + case 1: pregs[A & 1] = V; Sync(); break; + case 2: IRQa = IRQCount = 0; X6502_IRQEnd(FCEU_IQEXT); break; + case 3: IRQa = 1; X6502_IRQEnd(FCEU_IQEXT); break; + } +} + +static void M91Power(void) +{ + Sync(); + SetWriteHandler(0x6000,0x6fff,M91Write0); + SetWriteHandler(0x7000,0x7fff,M91Write1); + SetReadHandler(0x8000,0xffff,CartBR); +} + +static void M91IRQHook(void) +{ + if(IRQCount<8 && IRQa) + { + IRQCount++; + if(IRQCount>=8) + { + X6502_IRQBegin(FCEU_IQEXT); + } + } +} + +static void StateRestore(int version) +{ + Sync(); +} + +void Mapper91_Init(CartInfo *info) +{ + info->Power=M91Power; + GameHBIRQHook=M91IRQHook; + GameStateRestore=StateRestore; + AddExState(&StateRegs, ~0, 0, 0); +}