X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=fceu.git;a=blobdiff_plain;f=boards%2Fbmc70in1.c;h=75baaa5c1c421c5f199aeed13246c528a8bd1fb3;hp=9d4eb2890232d849f5807c6f12ad0234e98a4840;hb=386f5371eb984fb9c2860c83e740890a75cd45c1;hpb=eec2623f6183dd0f9494b99065a16bf90f2a1ccf diff --git a/boards/bmc70in1.c b/boards/bmc70in1.c index 9d4eb28..75baaa5 100644 --- a/boards/bmc70in1.c +++ b/boards/bmc70in1.c @@ -1,116 +1,130 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 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 is_large_banks; -static uint8 large_bank; -static uint8 prg_bank; -static uint8 chr_bank; -static uint8 bank_mode; -static uint8 mirroring; -static SFORMAT StateRegs[]= -{ - {&large_bank, 1, "LB"}, - {&prg_bank, 1, "PRG"}, - {&chr_bank, 1, "CHR"}, - {&bank_mode, 1, "BM"}, - {&mirroring, 1, "MIRR"}, - {0} -}; - -static void Sync(void) -{ - switch (bank_mode) - { - case 0x00: - case 0x10: setprg16(0x8000,large_bank|prg_bank); - setprg16(0xC000,large_bank|7); - break; - case 0x20: setprg32(0x8000,(large_bank|prg_bank)>>1); - break; - case 0x30: setprg16(0x8000,large_bank|prg_bank); - setprg16(0xC000,large_bank|prg_bank); - break; - } - setmirror(mirroring); - if(!is_large_banks) - setchr8(chr_bank); -} - -static DECLFR(BMC70in1Read) -{ - if(bank_mode==0x10) - if(is_large_banks) - return CartBR((A&0xFFF0)|0x06); - else - return CartBR((A&0xFFF0)|0x0d); - else - return CartBR(A); -} - -static DECLFW(BMC70in1Write) -{ - if(A&0x4000) - { - bank_mode=A&0x30; - prg_bank=A&7; - } - else - { - mirroring=((A&0x20)>>5)^1; - if(is_large_banks) - large_bank=(A&3)<<3; - else - chr_bank=A&7; - } - Sync(); -} - -static void BMC70in1Power(void) -{ - setchr8(0); - bank_mode=0; - large_bank=0; - Sync(); - SetReadHandler(0x8000,0xFFFF,BMC70in1Read); - SetWriteHandler(0x8000,0xffff,BMC70in1Write); -} - -static void StateRestore(int version) -{ - Sync(); -} - -void BMC70in1_Init(CartInfo *info) -{ - is_large_banks=0; - info->Power=BMC70in1Power; - GameStateRestore=StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -void BMC70in1B_Init(CartInfo *info) -{ - is_large_banks=1; - info->Power=BMC70in1Power; - GameStateRestore=StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "mapinc.h" + +static uint8 is_large_banks, hw_switch; +static uint8 large_bank; +static uint8 prg_bank; +static uint8 chr_bank; +static uint8 bank_mode; +static uint8 mirroring; +static SFORMAT StateRegs[]= +{ + {&large_bank, 1, "LB"}, + {&hw_switch, 1, "DIPSW"}, + {&prg_bank, 1, "PRG"}, + {&chr_bank, 1, "CHR"}, + {&bank_mode, 1, "BM"}, + {&mirroring, 1, "MIRR"}, + {0} +}; + +static void Sync(void) +{ + switch (bank_mode) + { + case 0x00: + case 0x10: setprg16(0x8000,large_bank|prg_bank); + setprg16(0xC000,large_bank|7); + break; + case 0x20: setprg32(0x8000,(large_bank|prg_bank)>>1); + break; + case 0x30: setprg16(0x8000,large_bank|prg_bank); + setprg16(0xC000,large_bank|prg_bank); + break; + } + setmirror(mirroring); + if(!is_large_banks) + setchr8(chr_bank); +} + +static DECLFR(BMC70in1Read) +{ + if(bank_mode==0x10) +// if(is_large_banks) + return CartBR((A&0xFFF0)|hw_switch); +// else +// return CartBR((A&0xFFF0)|hw_switch); + else + return CartBR(A); +} + +static DECLFW(BMC70in1Write) +{ + if(A&0x4000) + { + bank_mode=A&0x30; + prg_bank=A&7; + } + else + { + mirroring=((A&0x20)>>5)^1; + if(is_large_banks) + large_bank=(A&3)<<3; + else + chr_bank=A&7; + } + Sync(); +} + +static void BMC70in1Reset(void) +{ + bank_mode=0; + large_bank=0; + Sync(); + hw_switch++; + hw_switch&=0xf; +} + +static void BMC70in1Power(void) +{ + setchr8(0); + bank_mode=0; + large_bank=0; + Sync(); + SetReadHandler(0x8000,0xFFFF,BMC70in1Read); + SetWriteHandler(0x8000,0xffff,BMC70in1Write); +} + +static void StateRestore(int version) +{ + Sync(); +} + +void BMC70in1_Init(CartInfo *info) +{ + is_large_banks=0; + hw_switch=0xd; + info->Power=BMC70in1Power; + info->Reset=BMC70in1Reset; + GameStateRestore=StateRestore; + AddExState(&StateRegs, ~0, 0, 0); +} + +void BMC70in1B_Init(CartInfo *info) +{ + is_large_banks=1; + hw_switch=0x6; + info->Power=BMC70in1Power; + info->Reset=BMC70in1Reset; + GameStateRestore=StateRestore; + AddExState(&StateRegs, ~0, 0, 0); +}