diff --git a/boards/112.c b/boards/112.c deleted file mode 100644 index 2bb1e4b8..00000000 --- a/boards/112.c +++ /dev/null @@ -1,90 +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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static uint8 reg[8]; -static uint8 mirror, cmd; -static uint8 *WRAM=NULL; - -static SFORMAT StateRegs[]= -{ - {&cmd, 1, "CMD"}, - {&mirror, 1, "MIRR"}, - {reg, 8, "REGS"}, - {0} -}; - -static void Sync(void) -{ - setmirror(mirror^1); - setprg8(0x8000,reg[0]); - setprg8(0xA000,reg[1]); - setchr2(0x0000,reg[2]>>1); - setchr2(0x0800,reg[3]>>1); - setchr1(0x1000,reg[4]); - setchr1(0x1400,reg[5]); - setchr1(0x1800,reg[6]); - setchr1(0x1C00,reg[7]); -} - -static DECLFW(M112Write) -{ - switch(A) - { - case 0xe000: mirror=V&1; Sync(); ;break; - case 0x8000: cmd=V&7; break; - case 0xa000: reg[cmd]=V; Sync(); break; - } -FCEU_printf("%04x:%04x %d\n",A,V,scanline); -} - -static void M112Close(void) -{ - if(WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void M112Power(void) -{ - setprg16(0xC000,~0); - setprg8r(0x10,0x6000,0); - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x8000,0xFFFF,M112Write); - SetReadHandler(0x6000,0x7FFF,CartBR); - SetWriteHandler(0x6000,0x7FFF,CartBW); -} - -static void StateRestore(int version) -{ - Sync(); -} - -void Mapper112_Init(CartInfo *info) -{ - info->Power=M112Power; - info->Close=M112Close; - GameStateRestore=StateRestore; - WRAM=(uint8*)FCEU_gmalloc(8192); - SetupCartPRGMapping(0x10,WRAM,8192,1); - AddExState(WRAM, 8192, 0, "WRAM"); - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/boards/117.c b/boards/117.c deleted file mode 100644 index 67460151..00000000 --- a/boards/117.c +++ /dev/null @@ -1,101 +0,0 @@ -/* 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); -} - diff --git a/boards/164.c b/boards/164.c deleted file mode 100644 index 0bb85b3e..00000000 --- a/boards/164.c +++ /dev/null @@ -1,116 +0,0 @@ -/* 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 cmd; -static uint8 DRegs[8]; -static SFORMAT StateRegs[]= -{ - {&cmd, 1, "CMD"}, - {DRegs, 8, "DREG"}, - {0} -}; - -static void Sync(void) -{ - setprg32(0x8000,(DRegs[0]<<4)|(DRegs[1]&0xF)); - setchr8(0); -} - -static void StateRestore(int version) -{ - Sync(); -} - -static DECLFW(Write) -{ - switch (A&0x7300) - { - case 0x5100: DRegs[0]=V; Sync(); break; - case 0x5000: DRegs[1]=V; Sync(); break; - } -} - -static DECLFW(Write2) -{ - switch (A&0x7300) - { - case 0x5200: DRegs[0]=V; Sync(); break; - case 0x5000: DRegs[1]=V; Sync(); break; - } -} - -static uint8 WRAM[8192]; -static DECLFR(AWRAM) -{ - return(WRAM[A-0x6000]); -} - -static DECLFW(BWRAM) -{ - WRAM[A-0x6000]=V; -} - -static void Power(void) -{ - memset(DRegs,0,8); - DRegs[1]=0xFF; - cmd=0; - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x4020,0xFFFF,Write); - SetReadHandler(0x6000,0x7FFF,AWRAM); - SetWriteHandler(0x6000,0x7FFF,BWRAM); - Sync(); -} - -static void M163HB(void) -{ - if(scanline==127&&DRegs[1]&0x80) - setchr4(0x0000,1); -} - - -static void Power2(void) -{ - memset(DRegs,0,8); - DRegs[1]=0xFF; - cmd=0; - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x4020,0xFFFF,Write2); - SetReadHandler(0x6000,0x7FFF,AWRAM); - SetWriteHandler(0x6000,0x7FFF,BWRAM); - Sync(); -} - -void Mapper164_Init(CartInfo *info) -{ - info->Power=Power; - GameStateRestore=StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -void Mapper163_Init(CartInfo *info) -{ - info->Power=Power2; - GameHBIRQHook=M163HB; - GameStateRestore=StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/boards/183.c b/boards/183.c deleted file mode 100644 index 94cf0726..00000000 --- a/boards/183.c +++ /dev/null @@ -1,117 +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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Gimmick Bootleg - */ - -#include "mapinc.h" - -static uint8 prg[4]; -static uint8 chr[8]; -static uint8 IRQCount; -static uint8 IRQPre; -static uint8 IRQa; - -static SFORMAT StateRegs[]= -{ - {prg, 4, "PRG"}, - {chr, 8, "CHR"}, - {&IRQCount, 1, "IRQCOUNT"}, - {&IRQPre, 1, "IRQPRE"}, - {&IRQa, 1, "IRQA"}, - {0} -}; - -static void SyncPrg(void) -{ - setprg8(0x6000,0); - setprg8(0x8000,prg[0]); - setprg8(0xA000,prg[1]); - setprg8(0xC000,prg[2]); - setprg8(0xE000,~0); -} - -static void SyncChr(void) -{ - int i; - for(i=0; i<8; i++) - setchr1(i<<10,chr[i]); -} - -static void StateRestore(int version) -{ - SyncPrg(); - SyncChr(); -} - -static DECLFW(M183Write) -{ - if(((A&0xF80C)>=0xB000)&&((A&0xF80C)<=0xE00C)) - { - uint8 index=(((A&0x7000)>>11)-6)|((A&8)>>3); - chr[index]=(chr[index]&(0xF0>>(A&4)))|((V&0x0F)<<(A&4)); - SyncChr(); - } - else switch (A&0xF80C) - { - case 0x8800: prg[0]=V; SyncPrg(); break; - case 0xA800: prg[1]=V; SyncPrg(); break; - case 0xA000: prg[2]=V; SyncPrg(); break; - case 0x9800: switch (V&3) - { - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } - break; - case 0xF000: IRQCount=((IRQCount&0xF0)|(V&0xF)); break; - case 0xF004: IRQCount=((IRQCount&0x0F)|((V&0xF)<<4)); break; - case 0xF008: IRQa=V; if(!V)IRQPre=0; X6502_IRQEnd(FCEU_IQEXT); break; - case 0xF00C: IRQPre=16; break; - } -} - -static void M183IRQCounter(void) -{ - if(IRQa) - { - IRQCount++; - if((IRQCount-IRQPre)==238) - X6502_IRQBegin(FCEU_IQEXT); - } -} - -static void M183Power(void) -{ - IRQPre=IRQCount=IRQa=0; - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x8000,0xFFFF,M183Write); - SetReadHandler(0x6000,0x7FFF,CartBR); - SyncPrg(); - SyncChr(); -} - -void Mapper183_Init(CartInfo *info) -{ - info->Power=M183Power; - GameHBIRQHook=M183IRQCounter; - GameStateRestore=StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/boards/185.c b/boards/185.c deleted file mode 100644 index ef560c57..00000000 --- a/boards/185.c +++ /dev/null @@ -1,116 +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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Family Study Box by Fukutake Shoten - */ - -#include "mapinc.h" - -static uint8 *DummyCHR=NULL; -static uint8 datareg; -static void(*Sync)(void); - - -static SFORMAT StateRegs[]= -{ - {&datareg, 1, "DREG"}, - {0} -}; - -// on off -//1 0x0F, 0xF0 - Bird Week -//2 0x33, 0x00 - B-Wings -//3 0x11, 0x00 - Mighty Bomb Jack -//4 0x22, 0x20 - Sansuu 1 Nen, Sansuu 2 Nen -//5 0xFF, 0x00 - Sansuu 3 Nen -//6 0x21, 0x13 - Spy vs Spy -//7 0x20, 0x21 - Seicross - -static void Sync185(void) -{ - // little dirty eh? ;_) - if((datareg&3)&&(datareg!=0x13)) // 1, 2, 3, 4, 5, 6 - setchr8(0); - else - setchr8r(0x10,0); -} - -static void Sync181(void) -{ - if(!(datareg&1)) // 7 - setchr8(0); - else - setchr8r(0x10,0); -} - -static DECLFW(MWrite) -{ - datareg=V; - Sync(); -} - -static void MPower(void) -{ - datareg=0; - Sync(); - setprg16(0x8000,0); - setprg16(0xC000,~0); - SetWriteHandler(0x8000,0xFFFF,MWrite); - SetReadHandler(0x8000,0xFFFF,CartBR); -} - -static void MClose(void) -{ - if(DummyCHR) - FCEU_gfree(DummyCHR); - DummyCHR=NULL; -} - -static void MRestore(int version) -{ - Sync(); -} - -void Mapper185_Init(CartInfo *info) -{ - Sync=Sync185; - info->Power=MPower; - info->Close=MClose; - GameStateRestore=MRestore; - DummyCHR=(uint8*)FCEU_gmalloc(8192); - int x; - for(x=0;x<8192;x++) - DummyCHR[x]=0xff; - SetupCartCHRMapping(0x10,DummyCHR,8192,0); - AddExState(StateRegs, ~0, 0, 0); -} - -void Mapper181_Init(CartInfo *info) -{ - Sync=Sync181; - info->Power=MPower; - info->Close=MClose; - GameStateRestore=MRestore; - DummyCHR=(uint8*)FCEU_gmalloc(8192); - int x; - for(x=0;x<8192;x++) - DummyCHR[x]=0xff; - SetupCartCHRMapping(0x10,DummyCHR,8192,0); - AddExState(StateRegs, ~0, 0, 0); -} diff --git a/boards/186.c b/boards/186.c deleted file mode 100644 index 3698c6ca..00000000 --- a/boards/186.c +++ /dev/null @@ -1,104 +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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Family Study Box by Fukutake Shoten - */ - -#include "mapinc.h" - -static uint8 SWRAM[2816]; -static uint8 *WRAM=NULL; -static uint8 regs[4]; - -static SFORMAT StateRegs[]= -{ - {regs, 4, "DREG"}, - {SWRAM, 2816, "SWRAM"}, - {0} -}; - -static void Sync(void) -{ - setprg8r(0x10,0x6000,regs[0]>>6); - setprg16(0x8000,regs[1]); - setprg16(0xc000,0); -} - -static DECLFW(M186Write) -{ - if(A&0x4203) regs[A&3]=V; - Sync(); -} - -static DECLFR(M186Read) -{ - switch(A) - { - case 0x4200: return 0x00; break; - case 0x4201: return 0x00; break; - case 0x4202: return 0x40; break; - case 0x4203: return 0x00; break; - } - return 0xFF; -} - -static DECLFR(ASWRAM) -{ - return(SWRAM[A-0x4400]); -} -static DECLFW(BSWRAM) -{ - SWRAM[A-0x4400]=V; -} - -static void M186Power(void) -{ - setchr8(0); - SetReadHandler(0x6000,0xFFFF,CartBR); - SetWriteHandler(0x6000,0xFFFF,CartBW); - SetReadHandler(0x4200,0x43FF,M186Read); - SetWriteHandler(0x4200,0x43FF,M186Write); - SetReadHandler(0x4400,0x4EFF,ASWRAM); - SetWriteHandler(0x4400,0x4EFF,BSWRAM); - regs[0]=regs[1]=regs[2]=regs[3]; - Sync(); -} - -static void M186Close(void) -{ - if(WRAM) - FCEU_gfree(WRAM); - WRAM=NULL; -} - -static void M186Restore(int version) -{ - Sync(); -} - -void Mapper186_Init(CartInfo *info) -{ - info->Power=M186Power; - info->Close=M186Close; - GameStateRestore=M186Restore; - WRAM=(uint8*)FCEU_gmalloc(32384); - SetupCartPRGMapping(0x10,WRAM,32384,1); - AddExState(WRAM, 32384, 0, "WRAM"); - AddExState(StateRegs, ~0, 0, 0); -} diff --git a/boards/187.c b/boards/187.c deleted file mode 100644 index 5f28bb5f..00000000 --- a/boards/187.c +++ /dev/null @@ -1,104 +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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" -#include "mmc3.h" - -static void M187CW(uint32 A, uint8 V) -{ - if((A&0x1000)==((MMC3_cmd&0x80)<<5)) - setchr1(A,V|0x100); - else - setchr1(A,V); -} - -static void M187PW(uint32 A, uint8 V) -{ - if(EXPREGS[0]&0x80) - { - uint8 bank=EXPREGS[0]&0x1F; - if(EXPREGS[0]&0x20) - setprg32(0x8000,bank>>2); - else - { - setprg16(0x8000,bank); - setprg16(0xC000,bank); - } - } - else - setprg8(A,V&0x3F); -} - -static DECLFW(M187Write8000) -{ - EXPREGS[2]=1; - MMC3_CMDWrite(A,V); -} - -static DECLFW(M187Write8001) -{ - if(EXPREGS[2]) - MMC3_CMDWrite(A,V); -} - -static DECLFW(M187Write8003) -{ - EXPREGS[2]=0; - if(V==0x28)setprg8(0xC000,0x17); - else if(V==0x2A)setprg8(0xA000,0x0F); -} - - -static DECLFW(M187WriteLo) -{ - EXPREGS[1]=V; - if(A==0x5000) - { - EXPREGS[0]=V; - FixMMC3PRG(MMC3_cmd); - } -} - -static uint8 prot_data[4] = { 0x83, 0x83, 0x42, 0x00 }; -static DECLFR(M187Read) -{ - return prot_data[EXPREGS[1]&3]; -} - -static void M187Power(void) -{ - EXPREGS[0]=EXPREGS[1]=EXPREGS[2]=0; - GenMMC3Power(); - Write_IRQFM(0x4017,0x40); - SetReadHandler(0x5000,0x5FFF,M187Read); - SetWriteHandler(0x5000,0x5FFF,M187WriteLo); - SetWriteHandler(0x8000,0x8000,M187Write8000); - SetWriteHandler(0x8001,0x8001,M187Write8001); - SetWriteHandler(0x8003,0x8003,M187Write8003); -} - -void Mapper187_Init(CartInfo *info) -{ - GenMMC3_Init(info, 256, 256, 0, 0); - pwrap=M187PW; - cwrap=M187CW; - info->Power=M187Power; - AddExState(EXPREGS, 3, 0, "EXPR"); -} diff --git a/boards/189.c b/boards/189.c deleted file mode 100644 index 445d099c..00000000 --- a/boards/189.c +++ /dev/null @@ -1,48 +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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" -#include "mmc3.h" - -static void M189PW(uint32 A, uint8 V) -{ - setprg32(0x8000,EXPREGS[0]&3); -} - -static DECLFW(M189Write) -{ - EXPREGS[0]=V|(V>>4); //actually, there is a two versions of 189 mapper with hi or lo bits bankswitching. - FixMMC3PRG(MMC3_cmd); -} - -static void M189Power(void) -{ - EXPREGS[0]=EXPREGS[1]=0; - GenMMC3Power(); - SetWriteHandler(0x4120,0x7FFF,M189Write); -} - -void Mapper189_Init(CartInfo *info) -{ - GenMMC3_Init(info, 256, 256, 0, 0); - pwrap=M189PW; - info->Power=M189Power; - AddExState(EXPREGS, 2, 0, "EXPR"); -} diff --git a/boards/208.c b/boards/208.c deleted file mode 100644 index 14156a6d..00000000 --- a/boards/208.c +++ /dev/null @@ -1,83 +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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" -#include "mmc3.h" - -static uint8 lut[256]={ - 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x59, 0x49, 0x19, 0x09, 0x59, 0x49, 0x19, 0x09, - 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x51, 0x41, 0x11, 0x01, 0x51, 0x41, 0x11, 0x01, - 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x59, 0x49, 0x19, 0x09, 0x59, 0x49, 0x19, 0x09, - 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x51, 0x41, 0x11, 0x01, 0x51, 0x41, 0x11, 0x01, - 0x00, 0x10, 0x40, 0x50, 0x00, 0x10, 0x40, 0x50,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x18, 0x48, 0x58, 0x08, 0x18, 0x48, 0x58,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x10, 0x40, 0x50, 0x00, 0x10, 0x40, 0x50,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x18, 0x48, 0x58, 0x08, 0x18, 0x48, 0x58,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x58, 0x48, 0x18, 0x08, 0x58, 0x48, 0x18, 0x08, - 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x50, 0x40, 0x10, 0x00, 0x50, 0x40, 0x10, 0x00, - 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x58, 0x48, 0x18, 0x08, 0x58, 0x48, 0x18, 0x08, - 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x50, 0x40, 0x10, 0x00, 0x50, 0x40, 0x10, 0x00, - 0x01, 0x11, 0x41, 0x51, 0x01, 0x11, 0x41, 0x51,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x09, 0x19, 0x49, 0x59, 0x09, 0x19, 0x49, 0x59,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x11, 0x41, 0x51, 0x01, 0x11, 0x41, 0x51,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x09, 0x19, 0x49, 0x59, 0x09, 0x19, 0x49, 0x59,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -static void M208PW(uint32 A, uint8 V) -{ - setprg32(0x8000,EXPREGS[5]); -} - -static DECLFW(M208Write) -{ - EXPREGS[5]=(V&0x1)|((V>>3)&0x2); - FixMMC3PRG(MMC3_cmd); -} - -static DECLFW(M208ProtWrite) -{ - if(A<=0x57FF) - EXPREGS[4]=V; - else - EXPREGS[(A&0x03)]=V^lut[EXPREGS[4]]; -} - -static DECLFR(M208ProtRead) -{ - return(EXPREGS[(A&0x3)]); -} - -static void M208Power(void) -{ - EXPREGS[5]=3; - GenMMC3Power(); - SetWriteHandler(0x4800,0x4FFF,M208Write); - SetWriteHandler(0x5000,0x5fff,M208ProtWrite); - SetReadHandler(0x5800,0x5FFF,M208ProtRead); - SetReadHandler(0x8000,0xffff,CartBR); -} - -void Mapper208_Init(CartInfo *info) -{ - GenMMC3_Init(info, 128, 256, 0, 0); - pwrap=M208PW; - info->Power=M208Power; - AddExState(EXPREGS, 6, 0, "EXPR"); -} diff --git a/boards/222.c b/boards/222.c deleted file mode 100644 index 1784314a..00000000 --- a/boards/222.c +++ /dev/null @@ -1,99 +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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "mapinc.h" - -static uint16 IRQCount; -static uint8 IRQa; -static uint8 prg_reg[2]; -static uint8 chr_reg[8]; - -static SFORMAT StateRegs[]= -{ - {&IRQCount, 2, "IRQC"}, - {&IRQa, 2, "IRQA"}, - {prg_reg, 2, "PRG"}, - {chr_reg, 8, "CHR"}, - {0} -}; - -static void M222IRQ(void) -{ - if(IRQa) - { - IRQCount++; - if(IRQCount>=240) - { - X6502_IRQBegin(FCEU_IQEXT); - IRQa=0; - } - } -} - -static void Sync(void) -{ - setprg8(0x8000,prg_reg[0]); - setprg8(0xA000,prg_reg[1]); - int i; - for(i=0; i<8; i++) - setchr1(i<<10,chr_reg[i]); -} - -static DECLFW(M222Write) -{ - switch(A&0xF003) - { - case 0x8000: prg_reg[0]=V; break; - case 0xA000: prg_reg[1]=V; break; - case 0xB000: chr_reg[0]=V; break; - case 0xB002: chr_reg[1]=V; break; - case 0xC000: chr_reg[2]=V; break; - case 0xC002: chr_reg[3]=V; break; - case 0xD000: chr_reg[4]=V; break; - case 0xD002: chr_reg[5]=V; break; - case 0xE000: chr_reg[6]=V; break; - case 0xE002: chr_reg[7]=V; break; - case 0xF000: IRQCount=IRQa=V; - X6502_IRQEnd(FCEU_IQEXT); - break; - } - Sync(); -} - -static void M222Power(void) -{ - setprg16(0xC000,~0); - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x8000,0xFFFF,M222Write); -} - -static void StateRestore(int version) -{ - Sync(); -} - -void Mapper222_Init(CartInfo *info) -{ - info->Power=M222Power; - GameHBIRQHook=M222IRQ; - GameStateRestore=StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/boards/235.c b/boards/235.c deleted file mode 100644 index e866e39e..00000000 --- a/boards/235.c +++ /dev/null @@ -1,70 +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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static uint16 cmdreg; -static SFORMAT StateRegs[]= -{ - {&cmdreg, 2, "CMDREG"}, - {0} -}; - -static void Sync(void) -{ - if(cmdreg&0x400) - setmirror(MI_0); - else - setmirror(((cmdreg>>13)&1)^1); - if(cmdreg&0x800) - { - setprg16(0x8000,((cmdreg&0x300)>>3)|((cmdreg&0x1F)<<1)|((cmdreg>>12)&1)); - setprg16(0xC000,((cmdreg&0x300)>>3)|((cmdreg&0x1F)<<1)|((cmdreg>>12)&1)); - } - else - setprg32(0x8000,((cmdreg&0x300)>>4)|(cmdreg&0x1F)); -} - -static DECLFW(M235Write) -{ - cmdreg=A; - Sync(); -} - -static void M235Power(void) -{ - setchr8(0); - SetWriteHandler(0x8000,0xFFFF,M235Write); - SetReadHandler(0x8000,0xFFFF,CartBR); - cmdreg=0; - Sync(); -} - -static void M235Restore(int version) -{ - Sync(); -} - -void Mapper235_Init(CartInfo *info) -{ - info->Power=M235Power; - GameStateRestore=M235Restore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/boards/57.c b/boards/57.c deleted file mode 100644 index 5a4f98a9..00000000 --- a/boards/57.c +++ /dev/null @@ -1,93 +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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "mapinc.h" - -static uint8 prg_reg; -static uint8 chr_reg; -static uint8 hrd_flag; - -static SFORMAT StateRegs[]= -{ - {&prg_reg, 1, "PRG"}, - {&chr_reg, 1, "CHR"}, - {0} -}; - -static void Sync(void) -{ - if(prg_reg&0x80) - setprg32(0x8000,prg_reg>>6); - else - { - setprg16(0x8000,(prg_reg>>5)&3); - setprg16(0xC000,(prg_reg>>5)&3); - } - setmirror((prg_reg&8)>>3); - setchr8((chr_reg&3)|(prg_reg&7)|((prg_reg&0x10)>>1)); -} - -static DECLFR(M57Read) -{ - return hrd_flag; -} - -static DECLFW(M57Write) -{ - if((A&0x8800)==0x8800) - prg_reg=V; - else - chr_reg=V; - Sync(); -} - -static void M57Power(void) -{ - prg_reg=0; - chr_reg=0; - hrd_flag=0; - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x8000,0xFFFF,M57Write); - SetReadHandler(0x6000,0x6000,M57Read); - Sync(); -} - -static void M57Reset() -{ - if(hrd_flag==3) - hrd_flag=0; - else - hrd_flag++; - FCEU_printf("Select Register = %02x\n",hrd_flag); -} - -static void StateRestore(int version) -{ - Sync(); -} - -void Mapper57_Init(CartInfo *info) -{ - info->Power=M57Power; - info->Reset=M57Reset; - GameStateRestore=StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/boards/8157.c b/boards/8157.c deleted file mode 100644 index 91e45fef..00000000 --- a/boards/8157.c +++ /dev/null @@ -1,80 +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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static uint16 cmdreg; -static uint8 invalid_data; -static SFORMAT StateRegs[]= -{ - {&cmdreg, 2, "CMDREG"}, - {0} -}; - -static void Sync(void) -{ - setprg16r((cmdreg&0x060)>>5,0x8000,(cmdreg&0x01C)>>2); - setprg16r((cmdreg&0x060)>>5,0xC000,(cmdreg&0x200)?(~0):0); - setmirror(((cmdreg&2)>>1)^1); -} - -static DECLFR(UNL8157Read) -{ - if(invalid_data&&cmdreg&0x100) - return 0xFF; - else - return CartBR(A); -} - -static DECLFW(UNL8157Write) -{ - cmdreg=A; - Sync(); -} - -static void UNL8157Power(void) -{ - setchr8(0); - SetWriteHandler(0x8000,0xFFFF,UNL8157Write); - SetReadHandler(0x8000,0xFFFF,UNL8157Read); - cmdreg=0x200; - invalid_data=1; - Sync(); -} - -static void UNL8157Reset(void) -{ - cmdreg=0; - invalid_data^=1; - Sync(); -} - -static void UNL8157Restore(int version) -{ - Sync(); -} - -void UNL8157_Init(CartInfo *info) -{ - info->Power=UNL8157Power; - info->Reset=UNL8157Reset; - GameStateRestore=UNL8157Restore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/boards/8237.c b/boards/8237.c deleted file mode 100644 index 5b4e2df1..00000000 --- a/boards/8237.c +++ /dev/null @@ -1,93 +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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" -#include "mmc3.h" - -static uint8 cmdin; -static uint8 UNL8237_perm[8] = {0, 2, 6, 1, 7, 3, 4, 5}; - -static void UNL8237CW(uint32 A, uint8 V) -{ - setchr1(A,((EXPREGS[1]&4)<<6)|V); -} - -static void UNL8237PW(uint32 A, uint8 V) -{ - if(EXPREGS[0]&0x80) - { - if(EXPREGS[0]&0x20) - setprg32(0x8000,(EXPREGS[0]&0xF)>>1); - else - { - setprg16(0x8000,(EXPREGS[0]&0x1F)); - setprg16(0xC000,(EXPREGS[0]&0x1F)); - } - } - else - setprg8(A,V&0x3F); -} - -static DECLFW(UNL8237Write) -{ - if((A&0xF000)==0xF000) - IRQCount=V; - else if((A&0xF000)==0xE000) - X6502_IRQEnd(FCEU_IQEXT); - else switch(A&0xE001) - { - case 0x8000: setmirror(((V|(V>>7))&1)^1); break; - case 0xA000: MMC3_CMDWrite(0x8000,(V&0xC0)|(UNL8237_perm[V&7])); cmdin=1; break; - case 0xC000: if(cmdin) - { - MMC3_CMDWrite(0x8001,V); - cmdin=0; - } - break; - } -} - -static DECLFW(UNL8237ExWrite) -{ - switch(A) - { - case 0x5000: EXPREGS[0]=V; FixMMC3PRG(MMC3_cmd); break; - case 0x5001: EXPREGS[1]=V; FixMMC3CHR(MMC3_cmd); break; - } -} - -static void UNL8237Power(void) -{ - IRQa=1; - EXPREGS[0]=EXPREGS[1]=0; - GenMMC3Power(); - SetWriteHandler(0x8000,0xFFFF,UNL8237Write); - SetWriteHandler(0x5000,0x7FFF,UNL8237ExWrite); -} - -void UNL8237_Init(CartInfo *info) -{ - GenMMC3_Init(info, 256, 256, 0, 0); - cwrap=UNL8237CW; - pwrap=UNL8237PW; - info->Power=UNL8237Power; - AddExState(EXPREGS, 3, 0, "EXPR"); - AddExState(&cmdin, 1, 0, "CMDIN"); -} diff --git a/boards/88.c b/boards/88.c deleted file mode 100644 index 03fbf5ba..00000000 --- a/boards/88.c +++ /dev/null @@ -1,87 +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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static uint8 reg[8]; -static uint8 mirror, cmd, is154; - -static SFORMAT StateRegs[]= -{ - {&cmd, 1, "CMD"}, - {&mirror, 1, "MIRR"}, - {reg, 8, "REGS"}, - {0} -}; - -static void Sync(void) -{ - setchr2(0x0000,reg[0]>>1); - setchr2(0x0800,reg[1]>>1); - setchr1(0x1000,reg[2]|0x40); - setchr1(0x1400,reg[3]|0x40); - setchr1(0x1800,reg[4]|0x40); - setchr1(0x1C00,reg[5]|0x40); - setprg8(0x8000,reg[6]); - setprg8(0xA000,reg[7]); -} - -static void MSync(void) -{ - if(is154)setmirror(MI_0+(mirror&1)); -} - -static DECLFW(M88Write) -{ - switch(A&0x8001) - { - case 0x8000: cmd=V&7; mirror=V>>6; MSync(); break; - case 0x8001: reg[cmd]=V; Sync(); break; - } -} - -static void M88Power(void) -{ - setprg16(0xC000,~0); - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x8000,0xFFFF,M88Write); -} - -static void StateRestore(int version) -{ - Sync(); - MSync(); -} - -void Mapper88_Init(CartInfo *info) -{ - is154=0; - info->Power=M88Power; - GameStateRestore=StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -void Mapper154_Init(CartInfo *info) -{ - is154=1; - info->Power=M88Power; - GameStateRestore=StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/boards/90.c b/boards/90.c deleted file mode 100644 index 994910d7..00000000 --- a/boards/90.c +++ /dev/null @@ -1,466 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * 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" -//#define DEBUG90 - -static int is209; -static int is211; - -static uint8 IRQMode; // from $c001 -static uint8 IRQPre; // from $c004 -static uint8 IRQPreSize; // from $c007 -static uint8 IRQCount; // from $c005 -static uint8 IRQXOR; // Loaded from $C006 -static uint8 IRQa; // $c002, $c003, and $c000 - -static uint8 mul[2]; -static uint8 regie; - -static uint8 tkcom[4]; -static uint8 prgb[4]; -static uint8 chrlow[8]; -static uint8 chrhigh[8]; - -static uint16 names[4]; -static uint8 tekker; - -static SFORMAT Tek_StateRegs[]={ - {&IRQMode, 1, "IRQMODE"}, - {&IRQPre, 1, "IRQPRE"}, - {&IRQPreSize, 1, "IRQPRESIZE"}, - {&IRQCount, 1, "IRQC"}, - {&IRQXOR, 1, "IRQXOR"}, - {&IRQa, 1, "IRQa"}, - {mul, 2, "MUL"}, - {®ie, 1, "REGI"}, - {tkcom, 4, "TKCO"}, - {prgb, 4, "PRGB"}, - {chrlow, 4, "CHRL"}, - {chrhigh, 8, "CHRH"}, - {&names[0], 2|FCEUSTATE_RLSB, "NMS0"}, - {&names[1], 2|FCEUSTATE_RLSB, "NMS1"}, - {&names[2], 2|FCEUSTATE_RLSB, "NMS2"}, - {&names[3], 2|FCEUSTATE_RLSB, "NMS3"}, - {&tekker, 1, "TEKR"}, - {0} -}; - -static void mira(void) -{ - if((tkcom[0]&0x20&&is209)||is211) - { - int x; - if(tkcom[0]&0x40) // Name tables are ROM-only - { - for(x=0;x<4;x++) - setntamem(CHRptr[0]+(((names[x])&CHRmask1[0])<<10),0,x); - } - else // Name tables can be RAM or ROM. - { - for(x=0;x<4;x++) - { - if((tkcom[1]&0x80)==(names[x]&0x80)) // RAM selected. - setntamem(NTARAM+((names[x]&0x1)<<10),1,x); - else - setntamem(CHRptr[0]+(((names[x])&CHRmask1[0])<<10),0,x); - } - } - } - else - { - switch(tkcom[1]&3) - { - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } - } -} - -static void tekprom(void) -{ - uint32 bankmode=((tkcom[3]&6)<<5); - switch(tkcom[0]&7) - { - case 00: if(tkcom[0]&0x80) - setprg8(0x6000,(((prgb[3]<<2)+3)&0x3F)|bankmode); - setprg32(0x8000,0x0F|((tkcom[3]&6)<<3)); - break; - case 01: if(tkcom[0]&0x80) - setprg8(0x6000,(((prgb[3]<<1)+1)&0x3F)|bankmode); - setprg16(0x8000,(prgb[1]&0x1F)|((tkcom[3]&6)<<4)); - setprg16(0xC000,0x1F|((tkcom[3]&6)<<4)); - break; - case 03: // bit reversion - case 02: if(tkcom[0]&0x80) - setprg8(0x6000,(prgb[3]&0x3F)|bankmode); - setprg8(0x8000,(prgb[0]&0x3F)|bankmode); - setprg8(0xa000,(prgb[1]&0x3F)|bankmode); - setprg8(0xc000,(prgb[2]&0x3F)|bankmode); - setprg8(0xe000,0x3F|bankmode); - break; - case 04: if(tkcom[0]&0x80) - setprg8(0x6000,(((prgb[3]<<2)+3)&0x3F)|bankmode); - setprg32(0x8000,(prgb[3]&0x0F)|((tkcom[3]&6)<<3)); - break; - case 05: if(tkcom[0]&0x80) - setprg8(0x6000,(((prgb[3]<<1)+1)&0x3F)|bankmode); - setprg16(0x8000,(prgb[1]&0x1F)|((tkcom[3]&6)<<4)); - setprg16(0xC000,(prgb[3]&0x1F)|((tkcom[3]&6)<<4)); - break; - case 07: // bit reversion - case 06: if(tkcom[0]&0x80) - setprg8(0x6000,(prgb[3]&0x3F)|bankmode); - setprg8(0x8000,(prgb[0]&0x3F)|bankmode); - setprg8(0xa000,(prgb[1]&0x3F)|bankmode); - setprg8(0xc000,(prgb[2]&0x3F)|bankmode); - setprg8(0xe000,(prgb[3]&0x3F)|bankmode); - break; - } -} - -static void tekvrom(void) -{ - int x, bank=0, mask=0xFFFF; - if(!(tkcom[3]&0x20)) - { - bank=(tkcom[3]&1)|((tkcom[3]&0x18)>>2); - switch (tkcom[0]&0x18) - { - case 0x00: bank<<=5; mask=0x1F; break; - case 0x08: bank<<=6; mask=0x3F; break; - case 0x10: bank<<=7; mask=0x7F; break; - case 0x18: bank<<=8; mask=0xFF; break; - } - } - switch(tkcom[0]&0x18) - { - case 0x00: // 8KB - setchr8(((chrlow[0]|(chrhigh[0]<<8))&mask)|bank); - break; - case 0x08: // 4KB - for(x=0;x<8;x+=4) - setchr4(x<<10,((chrlow[x]|(chrhigh[x]<<8))&mask)|bank); - break; - case 0x10: // 2KB - for(x=0;x<8;x+=2) - setchr2(x<<10,((chrlow[x]|(chrhigh[x]<<8))&mask)|bank); - break; - case 0x18: // 1KB - for(x=0;x<8;x++) - setchr1(x<<10,((chrlow[x]|(chrhigh[x]<<8))&mask)|bank); - break; - } -} - -static DECLFW(M90TekWrite) -{ - switch(A) - { - case 0x5800: mul[0]=V; break; - case 0x5801: mul[1]=V; break; - case 0x5803: regie=V; break; - } -} - -static DECLFR(M90TekRead) -{ - switch(A) - { - case 0x5800: return (mul[0]*mul[1]); - case 0x5801: return((mul[0]*mul[1])>>8); - case 0x5803: return (regie); - } - return(tekker); -} - -static DECLFW(M90PRGWrite) -{ - prgb[A&3]=V; - tekprom(); -} - -static DECLFW(M90CHRlowWrite) -{ - chrlow[A&7]=V; - tekvrom(); -} - -static DECLFW(M90CHRhiWrite) -{ - chrhigh[A&7]=V; - tekvrom(); -} - -static DECLFW(M90NTWrite) -{ - if(A&4) - { - names[A&3]&=0x00FF; - names[A&3]|=V<<8; - } - else - { - names[A&3]&=0xFF00; - names[A&3]|=V; - } - mira(); -} - -static DECLFW(M90IRQWrite) -{ - switch(A&7) - { - case 00: //FCEU_printf("%s IRQ (C000)\n",V&1?"Enable":"Disable"); - IRQa=V&1;if(!(V&1)) X6502_IRQEnd(FCEU_IQEXT);break; - case 02: //FCEU_printf("Disable IRQ (C002) scanline=%d\n", scanline); - IRQa=0;X6502_IRQEnd(FCEU_IQEXT);break; - case 03: //FCEU_printf("Enable IRQ (C003) scanline=%d\n", scanline); - IRQa=1;break; - case 01: IRQMode=V; -/* FCEU_printf("IRQ Count method: "); - switch (IRQMode&3) - { - case 00: FCEU_printf("M2 cycles\n");break; - case 01: FCEU_printf("PPU A12 toggles\n");break; - case 02: FCEU_printf("PPU reads\n");break; - case 03: FCEU_printf("Writes to CPU space\n");break; - } - FCEU_printf("Counter prescaler size: %s\n",(IRQMode&4)?"3 bits":"8 bits"); - FCEU_printf("Counter prescaler size adjust: %s\n",(IRQMode&8)?"Used C007":"Normal Operation"); - if((IRQMode>>6)==2) FCEU_printf("Counter Down\n"); - else if((IRQMode>>6)==1) FCEU_printf("Counter Up\n"); - else FCEU_printf("Counter Stopped\n"); -*/ break; - case 04: //FCEU_printf("Pre Counter Loaded and Xored wiht C006: %d\n",V^IRQXOR); - IRQPre=V^IRQXOR;break; - case 05: //FCEU_printf("Main Counter Loaded and Xored wiht C006: %d\n",V^IRQXOR); - IRQCount=V^IRQXOR;break; - case 06: //FCEU_printf("Xor Value: %d\n",V); - IRQXOR=V;break; - case 07: //if(!(IRQMode&8)) FCEU_printf("C001 is clear, no effect applied\n"); - // else if(V==0xFF) FCEU_printf("Prescaler is changed for 12bits\n"); - // else FCEU_printf("Counter Stopped\n"); - IRQPreSize=V;break; - } -} - -static DECLFW(M90ModeWrite) -{ - tkcom[A&3]=V; - tekprom(); - tekvrom(); - mira(); - -#ifdef DEBUG90 - switch (A&3) - { - case 00: FCEU_printf("Main Control Register:\n"); - FCEU_printf(" PGR Banking mode: %d\n",V&7); - FCEU_printf(" CHR Banking mode: %d\n",(V>>3)&3); - FCEU_printf(" 6000-7FFF addresses mapping: %s\n",(V&0x80)?"Yes":"No"); - FCEU_printf(" Nametable control: %s\n",(V&0x20)?"Enabled":"Disabled"); - if(V&0x20) - FCEU_printf(" Nametable can be: %s\n",(V&0x40)?"ROM Only":"RAM or ROM"); - break; - case 01: FCEU_printf("Mirroring mode: "); - switch (V&3) - { - case 0: FCEU_printf("Vertical\n");break; - case 1: FCEU_printf("Horizontal\n");break; - case 2: FCEU_printf("Nametable 0 only\n");break; - case 3: FCEU_printf("Nametable 1 only\n");break; - } - FCEU_printf("Mirroring flag: %s\n",(V&0x80)?"On":"Off"); - break; - case 02: if((((tkcom[0])>>5)&3)==1) - FCEU_printf("Nametable ROM/RAM select mode: %d\n",V>>7); - break; - case 03: - FCEU_printf("CHR Banking mode: %s\n",(V&0x20)?"Entire CHR ROM":"256Kb Switching mode"); - if(!(V&0x20)) FCEU_printf("256K CHR bank number: %02x\n",(V&1)|((V&0x18)>>2)); - FCEU_printf("512K PRG bank number: %d\n",(V&6)>>1); - FCEU_printf("CHR Bank mirroring: %s\n",(V&0x80)?"Swapped":"Normal operate"); - } -#endif -} - -static void CCL(void) -{ - if((IRQMode>>6) == 1) // Count Up - { - IRQCount++; - if((IRQCount == 0) && IRQa) - { - X6502_IRQBegin(FCEU_IQEXT); - } - } - else if((IRQMode>>6) == 2) // Count down - { - IRQCount--; - if((IRQCount == 0xFF) && IRQa) - { - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -static void ClockCounter(void) -{ - uint8 premask; - - if(IRQMode & 0x4) - premask = 0x7; - else - premask = 0xFF; - if((IRQMode>>6) == 1) // Count up - { - IRQPre++; - if((IRQPre & premask) == 0) CCL(); - } - else if((IRQMode>>6) == 2) // Count down - { - IRQPre--; - if((IRQPre & premask) == premask) CCL(); - } -} - -void FP_FASTAPASS(1) CPUWrap(int a) -{ - int x; - if((IRQMode&3)==0) for(x=0;x>=6; - if(tekker>3) - tekker=0; - else - tekker++; - tekker<<=6; - FCEU_printf("tekker=%04x\n",tekker); - memset(tkcom,0x00,sizeof(tkcom)); - memset(prgb,0xff,sizeof(prgb)); - tekprom(); - tekvrom(); -} - -static void M90Restore(int version) -{ - tekprom(); - tekvrom(); - mira(); -} - -static void M90Power(void) -{ - SetWriteHandler(0x5000,0x5fff,M90TekWrite); - SetWriteHandler(0x8000,0x8fff,M90PRGWrite); - SetWriteHandler(0x9000,0x9fff,M90CHRlowWrite); - SetWriteHandler(0xA000,0xAfff,M90CHRhiWrite); - SetWriteHandler(0xB000,0xBfff,M90NTWrite); - SetWriteHandler(0xC000,0xCfff,M90IRQWrite); - SetWriteHandler(0xD000,0xDfff,M90ModeWrite); - - SetReadHandler(0x5000,0x5fff,M90TekRead); - SetReadHandler(0x6000,0xffff,CartBR); - - mul[0]=mul[1]=regie=0xFF; - - memset(tkcom,0x00,sizeof(tkcom)); - memset(prgb,0xff,sizeof(prgb)); - memset(chrlow,0xff,sizeof(chrlow)); - memset(chrhigh,0xff,sizeof(chrhigh)); - memset(names,0x00,sizeof(names)); - - if(is211) - tekker=0xC0; - else - tekker=0x00; - - tekprom(); - tekvrom(); -} - - -void Mapper90_Init(CartInfo *info) -{ - is211=0; - is209=0; - info->Reset=togglie; - info->Power=M90Power; - PPU_hook=M90PPU; - GameHBIRQHook2=SLWrap; - MapIRQHook=CPUWrap; - GameStateRestore=M90Restore; - AddExState(Tek_StateRegs, ~0, 0, 0); -} - -void Mapper209_Init(CartInfo *info) -{ - is211=0; - is209=1; - info->Reset=togglie; - info->Power=M90Power; - GameHBIRQHook2=SLWrap; - GameStateRestore=M90Restore; - AddExState(Tek_StateRegs, ~0, 0, 0); -} - -void Mapper211_Init(CartInfo *info) -{ - is211=1; - info->Reset=togglie; - info->Power=M90Power; - GameHBIRQHook2=SLWrap; - GameStateRestore=M90Restore; - AddExState(Tek_StateRegs, ~0, 0, 0); -} diff --git a/boards/95.c b/boards/95.c deleted file mode 100644 index 7b69435d..00000000 --- a/boards/95.c +++ /dev/null @@ -1,124 +0,0 @@ -/* 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 lastA; -static uint8 DRegs[8]; -static uint8 cmd; -static uint8 MirCache[8]; - -static SFORMAT DB_StateRegs[]={ - {DRegs, 8, "DREG"}, - {&cmd, 1, "CMD"}, - {&lastA, 1, "LAST"}, - {0} -}; - -static void toot(void) -{ - int x; - - MirCache[0]=MirCache[1]=(DRegs[0]>>4)&1; - MirCache[2]=MirCache[3]=(DRegs[1]>>4)&1; - - for(x=0;x<4;x++) - MirCache[4+x]=(DRegs[2+x]>>5)&1; - onemir(MirCache[lastA]); -} - -static void Sync() -{ - setchr2(0x0000,DRegs[0]&0x1F); - setchr2(0x0800,DRegs[1]&0x1F); - setchr1(0x1000,DRegs[2]&0x1F); - setchr1(0x1400,DRegs[3]&0x1F); - setchr1(0x1800,DRegs[4]&0x1F); - setchr1(0x1C00,DRegs[5]&0x1F); - setprg8(0x8000,DRegs[6]&0x1F); - setprg8(0xa000,DRegs[7]&0x1F); - toot(); -} - -static DECLFW(Mapper95_write) -{ - switch(A&0xF001) - { - case 0x8000: cmd = V; break; - case 0x8001: - switch(cmd&0x07) - { - case 0: DRegs[0]=(V&0x3F)>>1; break; - case 1: DRegs[1]=(V&0x3F)>>1; break; - case 2: DRegs[2]=V&0x3F; break; - case 3: DRegs[3]=V&0x3F; break; - case 4: DRegs[4]=V&0x3F; break; - case 5: DRegs[5]=V&0x3F; break; - case 6: DRegs[6]=V&0x3F; break; - case 7: DRegs[7]=V&0x3F; break; - } - Sync(); - } -} - -static void FP_FASTAPASS(1) dragonbust_ppu(uint32 A) -{ - static int last=-1; - static uint8 z; - - if(A>=0x2000) return; - - A>>=10; - lastA=A; - z=MirCache[A]; - if(z!=last) - { - onemir(z); - last=z; - } -} - -static void DBPower(void) -{ - memset(DRegs,0x3F,8); - DRegs[0]=DRegs[1]=0x1F; - - Sync(); - - setprg8(0xc000,0x3E); - setprg8(0xe000,0x3F); - - SetReadHandler(0x8000,0xffff,CartBR); - SetWriteHandler(0x8000,0xffff,Mapper95_write); -} - -static void StateRestore(int version) -{ - Sync(); -} - -void Mapper95_Init(CartInfo *info) -{ - info->Power=DBPower; - AddExState(DB_StateRegs, ~0, 0, 0); - PPU_hook=dragonbust_ppu; - GameStateRestore=StateRestore; -} - diff --git a/boards/Makefile.am.inc b/boards/Makefile.am.inc deleted file mode 100644 index bd1eb46f..00000000 --- a/boards/Makefile.am.inc +++ /dev/null @@ -1 +0,0 @@ -fceu_SOURCES += boards/112.c boards/117.c boards/164.c boards/183.c boards/185.c boards/186.c boards/187.c boards/189.c boards/208.c boards/222.c boards/235.c boards/57.c boards/8157.c boards/8237.c boards/88.c boards/90.c boards/95.c boards/bmc13in1jy110.c boards/bmc42in1r.c boards/bmc64in1nr.c boards/bmc70in1.c boards/bmcgk192.c boards/bonza.c boards/cc21.c boards/datalatch.c boards/deirom.c boards/dream.c boards/fk23c.c boards/h2288.c boards/karaoke.c boards/kof97.c boards/konami-qtai.c boards/malee.c boards/mmc1.c boards/mmc3.c boards/mmc5.c boards/n106.c boards/novel.c boards/sachen.c boards/sheroes.c boards/sl1632.c boards/sonic5.c boards/subor.c boards/super24.c boards/supervision.c boards/t-262.c boards/tengen.c boards/__dummy_mapper.c \ No newline at end of file diff --git a/boards/__dummy_mapper.c b/boards/__dummy_mapper.c deleted file mode 100644 index ac95ba9c..00000000 --- a/boards/__dummy_mapper.c +++ /dev/null @@ -1,96 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2006 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 reg[8]; -/* -static uint8 *WRAM=NULL; -static uint32 WRAMSIZE; -static uint8 *CHRRAM=NULL; -static uint32 CHRRAMSIZE; -*/ - -static SFORMAT StateRegs[]= -{ - {reg, 8, "REGS"}, - {0} -}; - -static void Sync(void) -{ -} - -static DECLFW(MNNNWrite) -{ -} - -static void MNNNPower(void) -{ - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x8000,0xFFFF,MNNNWrite); -} - -static void MNNNReset(void) -{ -} - -/* -static void MNNNClose(void) -{ - if(WRAM) - FCEU_gfree(WRAM); - if(CHRRAM) - FCEU_gfree(CHRRAM); - WRAM=CHRRAM=NULL; -} -*/ - -static void MNNNIRQHook(void) -{ - X6502_IRQBegin(FCEU_IQEXT); -} - -static void StateRestore(int version) -{ - Sync(); -} - -void MapperNNN_Init(CartInfo *info) -{ - info->Reset=MNNNReset; - info->Power=MNNNPower; -// info->Close=MNNNClose; - GameHBIRQHook=MNNNIRQHook; - GameStateRestore=StateRestore; -/* - CHRRAMSIZE=8192; - CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSIZE); - SetupCartPRGMapping(0x10,CHRRAM,CHRRAMSIZE,1); - AddExState(CHRRAM, CHRRAMSIZE, 0, "WRAM"); -*/ -/* - WRAMSIZE=8192; - WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); -*/ - AddExState(&StateRegs, ~0, 0, 0); -} \ No newline at end of file diff --git a/boards/bmc13in1jy110.c b/boards/bmc13in1jy110.c deleted file mode 100644 index 4909d3fa..00000000 --- a/boards/bmc13in1jy110.c +++ /dev/null @@ -1,103 +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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * BMC 42-in-1 reset switch - */ - -#include "mapinc.h" - -static uint8 bank_mode; -static uint8 bank_value; -static uint8 prgb[4]; -static SFORMAT StateRegs[]= -{ - {0} -}; - -static void Sync(void) -{ - FCEU_printf("%02x: %02x %02x\n", bank_mode, bank_value, prgb[0]); - switch(bank_mode&7) - { - case 0: - setprg32(0x8000,bank_value&7); break; - case 1: - setprg16(0x8000,((8+(bank_value&7))>>1)+prgb[1]); - setprg16(0xC000,(bank_value&7)>>1); - case 4: - setprg32(0x8000,8+(bank_value&7)); break; - case 5: - setprg16(0x8000,((8+(bank_value&7))>>1)+prgb[1]); - setprg16(0xC000,((8+(bank_value&7))>>1)+prgb[3]); - case 2: - setprg8(0x8000,prgb[0]>>2); - setprg8(0xa000,prgb[1]); - setprg8(0xc000,prgb[2]); - setprg8(0xe000,~0); - break; - case 3: - setprg8(0x8000,prgb[0]); - setprg8(0xa000,prgb[1]); - setprg8(0xc000,prgb[2]); - setprg8(0xe000,prgb[3]); - break; - } -} - -static DECLFW(BMC13in1JY110Write) -{ - FCEU_printf("%04x:%04x\n",A,V); - switch(A) - { - case 0x8000: - case 0x8001: - case 0x8002: - case 0x8003: prgb[A&3]=V; break; - case 0xD000: bank_mode=V; break; - case 0xD001: setmirror(V&3); - case 0xD002: break; - case 0xD003: bank_value=V; break; - } - Sync(); -} - -static void BMC13in1JY110Power(void) -{ - prgb[0]=prgb[1]=prgb[2]=prgb[3]=0; - bank_mode=0; - bank_value=0; - setprg32(0x8000,0); - setchr8(0); - SetWriteHandler(0x8000,0xFFFF,BMC13in1JY110Write); - SetReadHandler(0x8000,0xFFFF,CartBR); -} - -static void StateRestore(int version) -{ - Sync(); -} - -void BMC13in1JY110_Init(CartInfo *info) -{ - info->Power=BMC13in1JY110Power; - AddExState(&StateRegs, ~0, 0, 0); - GameStateRestore=StateRestore; -} - - diff --git a/boards/bmc42in1r.c b/boards/bmc42in1r.c deleted file mode 100644 index 340a4b8a..00000000 --- a/boards/bmc42in1r.c +++ /dev/null @@ -1,87 +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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * BMC 42-in-1 reset switch - */ - -#include "mapinc.h" - -static uint8 hrd_sw; -static uint8 latche; -static SFORMAT StateRegs[]= -{ - {&latche, 1, "LATCHE"}, - {&hrd_sw, 1, "HRDSW"}, - {0} -}; - -static void Sync(void) -{ - if(!(latche&0x20)) - setprg32r(hrd_sw,0x8000,(latche>>1)&0x0f); - else - { - setprg16r(hrd_sw,0x8000,latche&0x1f); - setprg16r(hrd_sw,0xC000,latche&0x1f); - } - switch((latche>>6)&3) - { - case 0: setmirrorw(0,0,0,1); break; - case 1: setmirror(MI_V); break; - case 2: setmirror(MI_H); break; - case 3: setmirror(MI_1); break; - } -} - -static DECLFW(BMC42in1rWrite) -{ - latche=V; - Sync(); -} - -static void BMC42in1rReset(void) -{ - hrd_sw^=1; - Sync(); -} - -static void BMC42in1rPower(void) -{ - latche=0x00; - hrd_sw=0; - setchr8(0); - Sync(); - SetWriteHandler(0x8000,0xFFFF,BMC42in1rWrite); - SetReadHandler(0x8000,0xFFFF,CartBR); -} - -static void StateRestore(int version) -{ - Sync(); -} - -void BMC42in1r_Init(CartInfo *info) -{ - info->Power=BMC42in1rPower; - info->Reset=BMC42in1rReset; - AddExState(&StateRegs, ~0, 0, 0); - GameStateRestore=StateRestore; -} - - diff --git a/boards/bmc64in1nr.c b/boards/bmc64in1nr.c deleted file mode 100644 index 888ef7a4..00000000 --- a/boards/bmc64in1nr.c +++ /dev/null @@ -1,93 +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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * BMC 42-in-1 reset switch - */ - -#include "mapinc.h" - -static uint8 regs[4]; - -static SFORMAT StateRegs[]= -{ - {regs, 4, "REGS"}, - {0} -}; - -static void Sync(void) -{ - if(regs[0]&0x80) - { - if(regs[1]&0x80) - setprg32(0x8000,regs[1]&0x1F); - else - { - int bank=((regs[1]&0x1f)<<1)|((regs[1]>>6)&1); - setprg16(0x8000,bank); - setprg16(0xC000,bank); - } - } - else - { - int bank=((regs[1]&0x1f)<<1)|((regs[1]>>6)&1); - setprg16(0xC000,bank); - } - if(regs[0]&0x20) - setmirror(MI_H); - else - setmirror(MI_V); - setchr8((regs[2]<<2)|((regs[0]>>1)&3)); -} - -static DECLFW(BMC64in1nrWriteLo) -{ - regs[A&3]=V; - Sync(); -} - -static DECLFW(BMC64in1nrWriteHi) -{ - regs[3]=V; - Sync(); -} - -static void BMC64in1nrPower(void) -{ - regs[0]=0x80; - regs[1]=0x43; - regs[2]=regs[3]=0; - Sync(); - SetWriteHandler(0x5000,0x5003,BMC64in1nrWriteLo); - SetWriteHandler(0x8000,0xFFFF,BMC64in1nrWriteHi); - SetReadHandler(0x8000,0xFFFF,CartBR); -} - -static void StateRestore(int version) -{ - Sync(); -} - -void BMC64in1nr_Init(CartInfo *info) -{ - info->Power=BMC64in1nrPower; - AddExState(&StateRegs, ~0, 0, 0); - GameStateRestore=StateRestore; -} - - diff --git a/boards/bmc70in1.c b/boards/bmc70in1.c deleted file mode 100644 index 81c5438d..00000000 --- a/boards/bmc70in1.c +++ /dev/null @@ -1,116 +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., 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); -} diff --git a/boards/bmcgk192.c b/boards/bmcgk192.c deleted file mode 100644 index 7484ba58..00000000 --- a/boards/bmcgk192.c +++ /dev/null @@ -1,67 +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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static uint16 addrlatche; - -static void Sync(void) -{ - if(addrlatche&0x40) - { - setprg16(0x8000,addrlatche&7); - setprg16(0xC000,addrlatche&7); - } - else - setprg32(0x8000,(addrlatche>>1)&3); - setchr8((addrlatche>>3)&7); - setmirror(((addrlatche&0x80)>>7)^1); -} - -static DECLFW(BMCGK192Write) -{ - addrlatche=A; - Sync(); -} - -static void BMCGK192Reset(void) -{ - setprg32(0x8000,0); -} - -static void BMCGK192Power(void) -{ - setprg32(0x8000,0); - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x8000,0xffff,BMCGK192Write); -} - -static void StateRestore(int version) -{ - Sync(); -} - -void Mapper58_Init(CartInfo *info) -{ - info->Power=BMCGK192Power; - info->Reset=BMCGK192Reset; - GameStateRestore=StateRestore; - AddExState(&addrlatche, 2, 0, "ALATC"); -} diff --git a/boards/bonza.c b/boards/bonza.c deleted file mode 100644 index 5e572f14..00000000 --- a/boards/bonza.c +++ /dev/null @@ -1,139 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 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 prg_reg; -static uint8 chr_reg; - -static uint8 sim0reg, sim0bit, sim0byte, sim0parity, sim0bcnt; -static uint16 sim0data; -static uint8 sim0array[128] = -{ - 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, - 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, - 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, - 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, - 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, - 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, - 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, - 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0xAA, -}; - -static SFORMAT StateRegs[]= -{ - {&prg_reg, 1, "PREG"}, - {&chr_reg, 1, "CREG"}, - {0} -}; - -static void Sync(void) -{ - setprg32(0x8000, prg_reg); - setchr8(chr_reg); -} - -static void StateRestore(int version) -{ - Sync(); -} - -static DECLFW(M216WriteHi) -{ -// FCEU_printf("%04x:%04x\n",A,V); - prg_reg=A&1; - chr_reg=(A&0x0E)>>1; - Sync(); -} - -static DECLFW(M216Write5000) -{ -// FCEU_printf("WRITE: %04x:%04x\n",A,V); - sim0reg=V; - if(!sim0reg) - { - sim0bit=sim0byte=sim0parity=0; - sim0data=sim0array[0]; - sim0bcnt=0x80; - } - else if(sim0reg&0x20) - { - sim0bcnt=0x20; - } -} - -static DECLFR(M216Read5000) -{ - if(sim0reg&0x60) - { - sim0reg=(sim0reg^(sim0reg<<1))&0x40; - return sim0reg; - } - else - { - uint8 sim0out=0; - if(sim0bit<8) - { -// sim0data=((sim0array[sim0byte]<<(sim0bit))&0x80)>>1; - sim0out=(sim0data&1)<<6; - sim0data>>=1; - sim0bit++; - sim0parity+=sim0data; - } - else if(sim0bit==8) - { - sim0bit++; - sim0out=sim0parity&1; - } - else if(sim0bit==9) - { - if(sim0byte==sim0bcnt) - sim0out=0x60; - else - { - sim0bit=0; - sim0byte++; - sim0data=sim0array[sim0byte]; - sim0out=0; - } - } -// FCEU_printf("READ: %04x (%04x-%02x,%04x)\n",A,X.PC,sim0out,sim0byte); - return sim0out; - } -} - -static void Power(void) -{ - prg_reg = 0; - chr_reg = 0; - Sync(); - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x8000,0xFFFF,M216WriteHi); - SetWriteHandler(0x5000,0x5000,M216Write5000); - SetReadHandler(0x5000,0x5000,M216Read5000); -} - - -void Mapper216_Init(CartInfo *info) -{ - info->Power=Power; - GameStateRestore=StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/boards/cc21.c b/boards/cc21.c deleted file mode 100644 index 9a171ae0..00000000 --- a/boards/cc21.c +++ /dev/null @@ -1,56 +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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static uint16 addrlatche; - -//------------------ UNLCC21 --------------------------- - -static void UNLCC21Sync(void) -{ - setchr8(addrlatche&1); - setmirror(MI_0+((addrlatche&2)>>1)); -} - -static DECLFW(UNLCC21Write) -{ - addrlatche=A; - UNLCC21Sync(); -} - -static void UNLCC21Power(void) -{ - setprg32(0x8000,0); - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x8000,0xffff,UNLCC21Write); -} - -static void UNLCC21Restore(int version) -{ - UNLCC21Sync(); -} - -void UNLCC21_Init(CartInfo *info) -{ - info->Power=UNLCC21Power; - GameStateRestore=UNLCC21Restore; - AddExState(&addrlatche, 2, 0, "ALATC"); -} diff --git a/boards/datalatch.c b/boards/datalatch.c deleted file mode 100644 index b3452fe1..00000000 --- a/boards/datalatch.c +++ /dev/null @@ -1,272 +0,0 @@ -/* 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 latche, latcheinit; -static uint16 addrreg0, addrreg1; -static void(*WSync)(void); - -static DECLFW(LatchWrite) -{ - latche=V; - WSync(); -} - -static void LatchPower(void) -{ - latche=latcheinit; - WSync(); - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(addrreg0,addrreg1,LatchWrite); -} - -static void StateRestore(int version) -{ - WSync(); -} - -void Latch_Init(CartInfo *info, void (*proc)(void), uint8 init, uint16 adr0, uint16 adr1) -{ - latcheinit=init; - addrreg0=adr0; - addrreg1=adr1; - WSync=proc; - info->Power=LatchPower; - GameStateRestore=StateRestore; - AddExState(&latche, 1, 0, "LATC"); -} - -//------------------ CPROM --------------------------- - -static void CPROMSync(void) -{ - setchr4(0x0000,0); - setchr4(0x1000,latche&3); - setprg16(0x8000,0); - setprg16(0xC000,1); -} - -void CPROM_Init(CartInfo *info) -{ - Latch_Init(info, CPROMSync, 0, 0x8000, 0xFFFF); -} - -//------------------ CNROM --------------------------- - -static void CNROMSync(void) -{ - setchr8(latche&3); - setprg16(0x8000,0); - setprg16(0xC000,1); -} - -void CNROM_Init(CartInfo *info) -{ - Latch_Init(info, CNROMSync, 0, 0x8000, 0xFFFF); -} - -//------------------ ANROM --------------------------- - -static void ANROMSync() -{ - setprg32(0x8000,latche&0xf); - setmirror(MI_0+((latche>>4)&1)); - setchr8(0); -} - -void ANROM_Init(CartInfo *info) -{ - Latch_Init(info, ANROMSync, 0, 0x8000, 0xFFFF); -} - -//------------------ Map 70 --------------------------- - -static void M70Sync() -{ - setprg16(0x8000,latche>>4); - setprg16(0xc000,~0); - setchr8(latche&0xf); -} - -void Mapper70_Init(CartInfo *info) -{ - Latch_Init(info, M70Sync, 0, 0x8000, 0xFFFF); -} - -//------------------ Map 152 --------------------------- - -static void M152Sync() -{ - setprg16(0x8000,(latche>>4)&7); - setprg16(0xc000,~0); - setchr8(latche&0xf); - setmirror(MI_0+((latche>>7)&1)); /* Saint Seiya...hmm. */ -} - -void Mapper152_Init(CartInfo *info) -{ - Latch_Init(info, M152Sync, 0, 0x8000, 0xFFFF); -} - -//------------------ Map 78 --------------------------- -/* Should be two separate emulation functions for this "mapper". Sigh. URGE TO KILL RISING. */ -static void M78Sync() -{ - setprg16(0x8000,(latche&7)); - setprg16(0xc000,~0); - setchr8(latche>>4); - setmirror(MI_0+((latche>>3)&1)); -} - -void Mapper78_Init(CartInfo *info) -{ - Latch_Init(info, M78Sync, 0, 0x8000, 0xFFFF); -} - -//------------------ MHROM --------------------------- - -static void MHROMSync(void) -{ - setprg32(0x8000,latche>>4); - setchr8(latche&0xf); -} - -void MHROM_Init(CartInfo *info) -{ - Latch_Init(info, MHROMSync, 0, 0x8000, 0xFFFF); -} - -void Mapper140_Init(CartInfo *info) -{ - Latch_Init(info, MHROMSync, 0, 0x6000, 0x7FFF); -} - -//------------------ Map 87 --------------------------- - -static void M87Sync(void) -{ - setprg16(0x8000,0); - setprg16(0xC000,1); - setchr8(latche>>1); -} - -void Mapper87_Init(CartInfo *info) -{ - Latch_Init(info, M87Sync, ~0, 0x6000, 0xFFFF); -} - -//------------------ Map 11 --------------------------- - -static void M11Sync(void) -{ - setprg32(0x8000,latche&0xf); - setchr8(latche>>4); -} - -void Mapper11_Init(CartInfo *info) -{ - Latch_Init(info, M11Sync, 0, 0x8000, 0xFFFF); -} - -void Mapper144_Init(CartInfo *info) -{ - Latch_Init(info, M11Sync, 0, 0x8001, 0xFFFF); -} - -//------------------ UNROM --------------------------- - -static void UNROMSync(void) -{ - setprg16(0x8000,latche); - setprg16(0xc000,~0); - setchr8(0); -} - -void UNROM_Init(CartInfo *info) -{ - Latch_Init(info, UNROMSync, 0, 0x8000, 0xFFFF); -} - -//------------------ Map 93 --------------------------- - -static void SSUNROMSync(void) -{ - setprg16(0x8000,latche>>4); - setprg16(0xc000,~0); - setchr8(0); -} - -void SUNSOFT_UNROM_Init(CartInfo *info) -{ - Latch_Init(info, SSUNROMSync, 0, 0x8000, 0xFFFF); -} - -//------------------ Map 94 --------------------------- - -static void M94Sync(void) -{ - setprg16(0x8000,latche>>2); - setprg16(0xc000,~0); - setchr8(0); -} - -void Mapper94_Init(CartInfo *info) -{ - Latch_Init(info, M94Sync, 0, 0x8000, 0xFFFF); -} - -//------------------ Map 107 --------------------------- - -static void M107Sync(void) -{ - setprg32(0x8000,(latche>>1)&3); - setchr8(latche&7); -} - -void Mapper107_Init(CartInfo *info) -{ - Latch_Init(info, M107Sync, ~0, 0x8000, 0xFFFF); -} - -//------------------ NROM --------------------------- - -#ifdef DEBUG_MAPPER -static DECLFW(WriteHandler) -{ - FCEU_printf("$%04x:$%02x\n",A,V); -} -#endif - -static void NROMPower(void) -{ - setprg16(0x8000,0); - setprg16(0xC000,~0); - setchr8(0); - SetReadHandler(0x8000,0xFFFF,CartBR); - #ifdef DEBUG_MAPPER - SetWriteHandler(0x4020,0xFFFF,WriteHandler); - #endif -} - -void NROM_Init(CartInfo *info) -{ - info->Power=NROMPower; -} diff --git a/boards/deirom.c b/boards/deirom.c deleted file mode 100644 index 7a1ed430..00000000 --- a/boards/deirom.c +++ /dev/null @@ -1,82 +0,0 @@ -/* 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 cmd; -static uint8 DRegs[8]; - -static SFORMAT DEI_StateRegs[]= -{ - {&cmd, 1, "CMD"}, - {DRegs, 8, "DREG"}, - {0} -}; - -static void Sync(void) -{ - setchr2(0x0000,DRegs[0]); - setchr2(0x0800,DRegs[1]); - int x; - for(x=0;x<4;x++) - setchr1(0x1000+(x<<10),DRegs[2+x]); - setprg8(0x8000,DRegs[6]); - setprg8(0xa000,DRegs[7]); -} - -static void StateRestore(int version) -{ - Sync(); -} - -static DECLFW(DEIWrite) -{ - switch(A&0x8001) - { - case 0x8000: cmd=V&0x07; break; - case 0x8001: if(cmd<=0x05) - V&=0x3F; - else - V&=0x0F; - if(cmd<=0x01) V>>=1; - DRegs[cmd&0x07]=V; - Sync(); - break; - } -} - -static void DEIPower(void) -{ - setprg8(0xc000,0xE); - setprg8(0xe000,0xF); - cmd=0; - memset(DRegs,0,8); - Sync(); - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x8000,0xFFFF,DEIWrite); -} - - -void DEIROM_Init(CartInfo *info) -{ - info->Power=DEIPower; - GameStateRestore=StateRestore; - AddExState(&DEI_StateRegs, ~0, 0, 0); -} diff --git a/boards/dream.c b/boards/dream.c deleted file mode 100644 index cf33afef..00000000 --- a/boards/dream.c +++ /dev/null @@ -1,56 +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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static uint8 latche; - -static void Sync(void) -{ - setprg16(0x8000,latche); - setprg16(0xC000,8); -} - -static DECLFW(DREAMWrite) -{ - latche=V&7; - Sync(); -} - -static void DREAMPower(void) -{ - latche=0; - Sync(); - setchr8(0); - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x5020,0x5020,DREAMWrite); -} - -static void Restore(int version) -{ - Sync(); -} - -void DreamTech01_Init(CartInfo *info) -{ - GameStateRestore=Restore; - info->Power=DREAMPower; - AddExState(&latche, 1, 0, "LATCH"); -} diff --git a/boards/fk23c.c b/boards/fk23c.c deleted file mode 100644 index 267c80c1..00000000 --- a/boards/fk23c.c +++ /dev/null @@ -1,112 +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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" -#include "mmc3.h" - -static uint8 unromchr; - -static void BMCFK23CCW(uint32 A, uint8 V) -{ - if(EXPREGS[0]&0x40) - setchr8((EXPREGS[2]&0xFC)|unromchr); - else - { - uint16 base=(EXPREGS[2]&0x7F)<<3; - setchr1(A,V|base); - if(EXPREGS[3]&2) - { - setchr1(0x0400,EXPREGS[6]|base); - setchr1(0x0C00,EXPREGS[7]|base); - } - } -} - -static void BMCFK23CPW(uint32 A, uint8 V) -{ - if(EXPREGS[0]&4) - setprg32(0x8000,EXPREGS[1]>>1); - else - { - if(EXPREGS[0]&2) - setprg8(A,(V&(0x3F>>(EXPREGS[0]&3)))|(EXPREGS[1]<<1)); - else - setprg8(A,V); - if(EXPREGS[3]&2) - { - setprg8(0xC000,EXPREGS[4]); - setprg8(0xE000,EXPREGS[5]); - } - } -} - -static DECLFW(BMCFK23C8003Write) -{ - if(EXPREGS[0]&0x40) - { - unromchr=V&3; - FixMMC3CHR(MMC3_cmd); - } - else - { - if((A==0x8001)&&(EXPREGS[3]&2&&MMC3_cmd&8)) - { - EXPREGS[4|(MMC3_cmd&3)]=V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); - } - else - MMC3_CMDWrite(A,V); - } -} - -static DECLFW(BMCFK23CWrite) -{ - EXPREGS[A&3]=V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void BMCFK23CReset(void) -{ - EXPREGS[0]=EXPREGS[1]=EXPREGS[2]=EXPREGS[3]=0; - EXPREGS[4]=EXPREGS[5]=EXPREGS[6]=EXPREGS[7]=0xFF; - MMC3RegReset(); -} - -static void BMCFK23CPower(void) -{ - EXPREGS[0]=EXPREGS[1]=EXPREGS[2]=EXPREGS[3]=0; - EXPREGS[4]=EXPREGS[5]=EXPREGS[6]=EXPREGS[7]=0xFF; - GenMMC3Power(); - SetWriteHandler(0x5ff0,0x5fff,BMCFK23CWrite); - SetWriteHandler(0x8000,0x8003,BMCFK23C8003Write); -} - -void BMCFK23C_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, 0); - cwrap=BMCFK23CCW; - pwrap=BMCFK23CPW; - info->Power=BMCFK23CPower; - info->Reset=BMCFK23CReset; - AddExState(EXPREGS, 8, 0, "EXPR"); - AddExState(&unromchr, 1, 0, "UNCHR"); -} diff --git a/boards/h2288.c b/boards/h2288.c deleted file mode 100644 index c2c66210..00000000 --- a/boards/h2288.c +++ /dev/null @@ -1,89 +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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" -#include "mmc3.h" - -extern uint8 m114_perm[8]; - -static void H2288PW(uint32 A, uint8 V) -{ - if(EXPREGS[0]&0x40) - { - uint8 bank=(EXPREGS[0]&5)|((EXPREGS[0]&8)>>2)|((EXPREGS[0]&0x20)>>2); - if(EXPREGS[0]&2) - setprg32(0x8000,bank>>1); - else - { - setprg16(0x8000,bank); - setprg16(0xC000,bank); - } - } - else - setprg8(A,V&0x3F); -} - -static DECLFW(H2288WriteHi) -{ - switch (A&0x8001) - { - case 0x8000: MMC3_CMDWrite(0x8000,(V&0xC0)|(m114_perm[V&7])); break; - case 0x8001: MMC3_CMDWrite(0x8001,V); break; - } -} - -static DECLFW(H2288WriteLo) -{ - if(A&0x800) - { - if(A&1) - EXPREGS[1]=V; - else - EXPREGS[0]=V; - FixMMC3PRG(MMC3_cmd); - } -} - -static DECLFR(H2288Read) -{ - int bit; - bit=(A&1)^1; - bit&=((A>>8)&1); - bit^=1; - return((X.DB&0xFE)|bit); -} - -static void H2288Power(void) -{ - EXPREGS[0]=EXPREGS[1]=0; - GenMMC3Power(); - SetReadHandler(0x5000,0x5FFF,H2288Read); - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x5000,0x5FFF,H2288WriteLo); - SetWriteHandler(0x8000,0x8FFF,H2288WriteHi); -} - -void UNLH2288_Init(CartInfo *info) -{ - GenMMC3_Init(info, 256, 256, 0, 0); - pwrap=H2288PW; - info->Power=H2288Power; - AddExState(EXPREGS, 2, 0, "EXPR"); -} diff --git a/boards/karaoke.c b/boards/karaoke.c deleted file mode 100644 index e089cda1..00000000 --- a/boards/karaoke.c +++ /dev/null @@ -1,71 +0,0 @@ -/* 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" - -extern uint32 ROM_size; -static uint8 latche; - -static void Sync(void) -{ - if(latche) - { - if(latche&0x10) - setprg16(0x8000,(latche&7)); - else - setprg16(0x8000,(latche&7)|8); - } - else - setprg16(0x8000,7+(ROM_size>>4)); -} - -static DECLFW(M188Write) -{ - latche=V; - Sync(); -} - -static DECLFR(ExtDev) -{ - return(3); -} - -static void Power(void) -{ - latche=0; - Sync(); - setchr8(0); - setprg16(0xc000,0x7); - SetReadHandler(0x6000,0x7FFF,ExtDev); - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x8000,0xFFFF,M188Write); -} - -static void StateRestore(int version) -{ - Sync(); -} - -void Mapper188_Init(CartInfo *info) -{ - info->Power=Power; - GameStateRestore=StateRestore; - AddExState(&latche, 1, 0, "LATCH"); -} diff --git a/boards/kof97.c b/boards/kof97.c deleted file mode 100644 index e40f4cf4..00000000 --- a/boards/kof97.c +++ /dev/null @@ -1,50 +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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" -#include "mmc3.h" - -static DECLFW(UNLKOF97CMDWrite) -{ - V=(V&0xD8)|((V&0x20)>>4)|((V&4)<<3)|((V&2)>>1)|((V&1)<<2); //76143502 - if(A==0x9000) A=0x8001; - MMC3_CMDWrite(A,V); -} - -static DECLFW(UNLKOF97IRQWrite) -{ - V=(V&0xD8)|((V&0x20)>>4)|((V&4)<<3)|((V&2)>>1)|((V&1)<<2); - if(A==0xD000) A=0xC001; - else if(A==0xF000) A=0xE001; - MMC3_IRQWrite(A,V); -} - -static void UNLKOF97Power(void) -{ - GenMMC3Power(); - SetWriteHandler(0x8000,0xA000,UNLKOF97CMDWrite); - SetWriteHandler(0xC000,0xF000,UNLKOF97IRQWrite); -} - -void UNLKOF97_Init(CartInfo *info) -{ - GenMMC3_Init(info, 128, 256, 0, 0); - info->Power=UNLKOF97Power; -} diff --git a/boards/konami-qtai.c b/boards/konami-qtai.c deleted file mode 100644 index ff552e10..00000000 --- a/boards/konami-qtai.c +++ /dev/null @@ -1,128 +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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * CAI Shogakko no Sansu - */ - -#include "mapinc.h" - -static uint8 *CHRRAM=NULL; -static uint8 SWRAM[4096]; - -static uint8 regs[16]; -static uint8 WRAM[4096]; -static SFORMAT StateRegs[]= -{ - {®s, 16, "REGS"}, - {WRAM, 4096, "WRAM"}, - {0} -}; - -static void Sync(void) -{ - if(regs[5]&0x40) - { - setchr4r(0,0x1000,regs[5]&0x3F); - } - else - { - setchr4r(0x10,0x0000,regs[5]); - setchr4r(0x10,0x1000,regs[5]^1); - } - setprg8r((regs[2]>>6)&1,0x8000,(regs[2]&0x3F)); - setprg8r((regs[3]>>6)&1,0xA000,(regs[3]&0x3F)); - setprg8r((regs[4]>>6)&1,0xC000,(regs[4]&0x3F)); - setprg8r(1,0xE000,~0); - setmirror((regs[0xA]&3)); -} - -static DECLFW(M190Write) -{ -// FCEU_printf("write %04x:%04x %d, %d\n",A,V,scanline,timestamp); - regs[(A&0x0F00)>>8]=V; - Sync(); -} - -static DECLFR(M190Read) -{ -// FCEU_printf("read %04x:%04x %d, %d\n",A,regs[(A&0x0F00)>>8],scanline,timestamp); - return regs[(A&0x0F00)>>8]; -} - -static DECLFR(AWRAM) -{ - return(WRAM[A-0x7000]); -} -static DECLFW(BWRAM) -{ - WRAM[A-0x7000]=V; -} - -static DECLFR(ASWRAM) -{ - return(SWRAM[A-0x6000]); -} -static DECLFW(BSWRAM) -{ - SWRAM[A-0x6000]=V; -} - -static void M190Power(void) -{ - setvram8(CHRRAM); - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x8000,0xFFFF,M190Write); -// SetReadHandler(0xDA00,0xDA00,M190Read); -// SetReadHandler(0xDB00,0xDB00,M190Read); - SetReadHandler(0xDC00,0xDC00,M190Read); - SetReadHandler(0xDD00,0xDD00,M190Read); - SetReadHandler(0x7000,0x7FFF,AWRAM); - SetWriteHandler(0x7000,0x7FFF,BWRAM); - SetReadHandler(0x6000,0x6FFF,ASWRAM); - SetWriteHandler(0x6000,0x6FFF,BSWRAM); - Sync(); -} - -static void M190Close(void) -{ - if(CHRRAM) - FCEU_gfree(CHRRAM); - CHRRAM=NULL; -} - -static void StateRestore(int version) -{ - Sync(); -} - -void Mapper190_Init(CartInfo *info) -{ - info->Power=M190Power; - info->Close=M190Close; - if(info->battery) - { - info->SaveGame[0]=SWRAM; - info->SaveGameLen[0]=4096; - } - GameStateRestore=StateRestore; - CHRRAM=(uint8*)FCEU_gmalloc(8192); - SetupCartCHRMapping(0x10,CHRRAM,8192,1); - AddExState(CHRRAM, 8192, 0, "CHRRAM"); - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/boards/malee.c b/boards/malee.c deleted file mode 100644 index 7feb95e1..00000000 --- a/boards/malee.c +++ /dev/null @@ -1,41 +0,0 @@ -/* 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 WRAM[2048]; - -static void MALEEReset(void) -{ - setprg2r(0x10,0x7000,0); - SetReadHandler(0x8000,0xFFFF,CartBR); - SetReadHandler(0x6000,0x67FF,CartBR); - SetReadHandler(0x7000,0x77FF,CartBR); - setprg2r(1,0x6000,0); - setprg32(0x8000,0); - setchr8(0); -} - -void MALEE_Init(CartInfo *info) -{ - info->Power=MALEEReset; - SetupCartPRGMapping(0x10, WRAM, 2048, 1); - AddExState(WRAM, 2048, 0,"RAM"); -} diff --git a/boards/mapinc.h b/boards/mapinc.h deleted file mode 100644 index eef1b4a2..00000000 --- a/boards/mapinc.h +++ /dev/null @@ -1,11 +0,0 @@ -#include "../types.h" -#include "../x6502.h" -#include "../fceu.h" -#include "../ppu.h" -#include "../memory.h" -#include "../sound.h" -#include "../state.h" -#include "../cart.h" -#include "../cheat.h" -#include "../unif.h" -#include diff --git a/boards/mmc1.c b/boards/mmc1.c deleted file mode 100644 index 29cf5b96..00000000 --- a/boards/mmc1.c +++ /dev/null @@ -1,423 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 1998 BERO - * 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 void GenMMC1Power(void); -static void GenMMC1Init(CartInfo *info, int prg, int chr, int wram, int battery); - -static uint8 DRegs[4]; -static uint8 Buffer,BufferShift; - -static int mmc1opts; - -static void (*MMC1CHRHook4)(uint32 A, uint8 V); -static void (*MMC1PRGHook16)(uint32 A, uint8 V); - -static uint8 *WRAM=NULL; -static uint8 *CHRRAM=NULL; -static int is155; - -static DECLFW(MBWRAM) -{ - if(!(DRegs[3]&0x10)||is155) - Page[A>>11][A]=V; // WRAM is enabled. -} - -static DECLFR(MAWRAM) -{ - if((DRegs[3]&0x10)&&!is155) - return X.DB; // WRAM is disabled - return(Page[A>>11][A]); -} - -static void MMC1CHR(void) -{ - if(mmc1opts&4) - { - if(DRegs[0]&0x10) - setprg8r(0x10,0x6000,(DRegs[1]>>4)&1); - else - setprg8r(0x10,0x6000,(DRegs[1]>>3)&1); - } - if(MMC1CHRHook4) - { - if(DRegs[0]&0x10) - { - MMC1CHRHook4(0x0000,DRegs[1]); - MMC1CHRHook4(0x1000,DRegs[2]); - } - else - { - MMC1CHRHook4(0x0000,(DRegs[1]&0xFE)); - MMC1CHRHook4(0x1000,DRegs[1]|1); - } - } - else - { - if(DRegs[0]&0x10) - { - setchr4(0x0000,DRegs[1]); - setchr4(0x1000,DRegs[2]); - } - else - setchr8(DRegs[1]>>1); - } -} - -static void MMC1PRG(void) -{ - uint8 offs=DRegs[1]&0x10; - if(MMC1PRGHook16) - { - switch(DRegs[0]&0xC) - { - case 0xC: MMC1PRGHook16(0x8000,(DRegs[3]+offs)); - MMC1PRGHook16(0xC000,0xF+offs); - break; - case 0x8: MMC1PRGHook16(0xC000,(DRegs[3]+offs)); - MMC1PRGHook16(0x8000,offs); - break; - case 0x0: - case 0x4: - MMC1PRGHook16(0x8000,((DRegs[3]&~1)+offs)); - MMC1PRGHook16(0xc000,((DRegs[3]&~1)+offs+1)); - break; - } - } - else switch(DRegs[0]&0xC) - { - case 0xC: setprg16(0x8000,(DRegs[3]+offs)); - setprg16(0xC000,0xF+offs); - break; - case 0x8: setprg16(0xC000,(DRegs[3]+offs)); - setprg16(0x8000,offs); - break; - case 0x0: - case 0x4: - setprg16(0x8000,((DRegs[3]&~1)+offs)); - setprg16(0xc000,((DRegs[3]&~1)+offs+1)); - break; - } -} - -static void MMC1MIRROR(void) -{ - switch(DRegs[0]&3) - { - case 2: setmirror(MI_V); break; - case 3: setmirror(MI_H); break; - case 0: setmirror(MI_0); break; - case 1: setmirror(MI_1); break; - } -} - -static uint64 lreset; -static DECLFW(MMC1_write) -{ - int n=(A>>13)-4; - //FCEU_DispMessage("%016x",timestampbase+timestamp); - //printf("$%04x:$%02x, $%04x\n",A,V,X.PC); - //DumpMem("out",0xe000,0xffff); - - /* The MMC1 is busy so ignore the write. */ - /* As of version FCE Ultra 0.81, the timestamp is only - increased before each instruction is executed(in other words - precision isn't that great), but this should still work to - deal with 2 writes in a row from a single RMW instruction. */ - if((timestampbase+timestamp)<(lreset+2)) return; - if(V&0x80) - { - DRegs[0]|=0xC; - BufferShift=Buffer=0; - MMC1PRG(); - lreset=timestampbase+timestamp; - return; - } - Buffer|=(V&1)<<(BufferShift++); - if(BufferShift==5) - { - DRegs[n] = Buffer; - BufferShift = Buffer = 0; - switch(n) - { - case 0: MMC1MIRROR(); MMC1CHR(); MMC1PRG(); break; - case 1: MMC1CHR(); MMC1PRG(); break; - case 2: MMC1CHR(); break; - case 3: MMC1PRG(); break; - } - } -} - -static void MMC1_Restore(int version) -{ - MMC1MIRROR(); - MMC1CHR(); - MMC1PRG(); - lreset=0; /* timestamp(base) is not stored in save states. */ -} - -static void MMC1CMReset(void) -{ - int i; - for(i=0;i<4;i++) - DRegs[i]=0; - Buffer = BufferShift = 0; - DRegs[0]=0x1F; - DRegs[1]=0; - DRegs[2]=0; // Should this be something other than 0? - DRegs[3]=0; - - MMC1MIRROR(); - MMC1CHR(); - MMC1PRG(); -} - -static int DetectMMC1WRAMSize(uint32 crc32) -{ - switch(crc32) - { - case 0xc6182024: /* Romance of the 3 Kingdoms */ - case 0x2225c20f: /* Genghis Khan */ - case 0x4642dda6: /* Nobunaga's Ambition */ - case 0x29449ba9: /* "" "" (J) */ - case 0x2b11e0b0: /* "" "" (J) */ - case 0xb8747abf: /* Best Play Pro Yakyuu Special (J) */ - case 0xc9556b36: /* Final Fantasy I & II (J) [!] */ - FCEU_printf(" >8KB external WRAM present. Use UNIF if you hack the ROM image.\n"); - return(16); - break; - default:return(8); - } -} - -static uint32 NWCIRQCount; -static uint8 NWCRec; -#define NWCDIP 0xE - -static void FP_FASTAPASS(1) NWCIRQHook(int a) -{ - if(!(NWCRec&0x10)) - { - NWCIRQCount+=a; - if((NWCIRQCount|(NWCDIP<<25))>=0x3e000000) - { - NWCIRQCount=0; - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -static void NWCCHRHook(uint32 A, uint8 V) -{ - if((V&0x10)) // && !(NWCRec&0x10)) - { - NWCIRQCount=0; - X6502_IRQEnd(FCEU_IQEXT); - } - NWCRec=V; - if(V&0x08) - MMC1PRG(); - else - setprg32(0x8000,(V>>1)&3); -} - -static void NWCPRGHook(uint32 A, uint8 V) -{ - if(NWCRec&0x8) - setprg16(A,8|(V&0x7)); - else - setprg32(0x8000,(NWCRec>>1)&3); -} - -static void NWCPower(void) -{ - GenMMC1Power(); - setchr8r(0,0); -} - -void Mapper105_Init(CartInfo *info) -{ - GenMMC1Init(info, 256, 256, 8, 0); - MMC1CHRHook4=NWCCHRHook; - MMC1PRGHook16=NWCPRGHook; - MapIRQHook=NWCIRQHook; - info->Power=NWCPower; -} - -static void GenMMC1Power(void) -{ - lreset=0; - if(mmc1opts&1) - { - FCEU_CheatAddRAM(8,0x6000,WRAM); - if(mmc1opts&4) - FCEU_dwmemset(WRAM,0,8192) - else if(!(mmc1opts&2)) - FCEU_dwmemset(WRAM,0,8192); - } - SetWriteHandler(0x8000,0xFFFF,MMC1_write); - SetReadHandler(0x8000,0xFFFF,CartBR); - - if(mmc1opts&1) - { - SetReadHandler(0x6000,0x7FFF,MAWRAM); - SetWriteHandler(0x6000,0x7FFF,MBWRAM); - setprg8r(0x10,0x6000,0); - } - - MMC1CMReset(); -} - -static void GenMMC1Close(void) -{ - if(CHRRAM) - FCEU_gfree(CHRRAM); - if(WRAM) - FCEU_gfree(WRAM); - CHRRAM=WRAM=NULL; -} - -static void GenMMC1Init(CartInfo *info, int prg, int chr, int wram, int battery) -{ - is155=0; - - info->Close=GenMMC1Close; - MMC1PRGHook16=MMC1CHRHook4=0; - mmc1opts=0; - PRGmask16[0]&=(prg>>14)-1; - CHRmask4[0]&=(chr>>12)-1; - CHRmask8[0]&=(chr>>13)-1; - - if(wram) - { - WRAM=(uint8*)FCEU_gmalloc(wram*1024); - mmc1opts|=1; - if(wram>8) mmc1opts|=4; - SetupCartPRGMapping(0x10,WRAM,wram*1024,1); - AddExState(WRAM, wram*1024, 0, "WRAM"); - if(battery) - { - mmc1opts|=2; - info->SaveGame[0]=WRAM+((mmc1opts&4)?8192:0); - info->SaveGameLen[0]=8192; - } - } - if(!chr) - { - CHRRAM=(uint8*)FCEU_gmalloc(8192); - SetupCartCHRMapping(0, CHRRAM, 8192, 1); - AddExState(CHRRAM, 8192, 0, "CHRR"); - } - AddExState(DRegs, 4, 0, "DREG"); - - info->Power=GenMMC1Power; - GameStateRestore=MMC1_Restore; - AddExState(&lreset, 8, 1, "LRST"); -} - -void Mapper1_Init(CartInfo *info) -{ - int ws=DetectMMC1WRAMSize(info->CRC32); - GenMMC1Init(info, 512, 256, ws, info->battery); -} - -/* Same as mapper 1, without respect for WRAM enable bit. */ -void Mapper155_Init(CartInfo *info) -{ - GenMMC1Init(info,512,256,8,info->battery); - is155=1; -} - -void SAROM_Init(CartInfo *info) -{ - GenMMC1Init(info, 128, 64, 8, info->battery); -} - -void SBROM_Init(CartInfo *info) -{ - GenMMC1Init(info, 128, 64, 0, 0); -} - -void SCROM_Init(CartInfo *info) -{ - GenMMC1Init(info, 128, 128, 0, 0); -} - -void SEROM_Init(CartInfo *info) -{ - GenMMC1Init(info, 32, 64, 0, 0); -} - -void SGROM_Init(CartInfo *info) -{ - GenMMC1Init(info, 256, 0, 0, 0); -} - -void SKROM_Init(CartInfo *info) -{ - GenMMC1Init(info, 256, 64, 8, info->battery); -} - -void SLROM_Init(CartInfo *info) -{ - GenMMC1Init(info, 256, 128, 0, 0); -} - -void SL1ROM_Init(CartInfo *info) -{ - GenMMC1Init(info, 128, 128, 0, 0); -} - -/* Begin unknown - may be wrong - perhaps they use different MMC1s from the - similarly functioning boards? -*/ - -void SL2ROM_Init(CartInfo *info) -{ - GenMMC1Init(info, 256, 256, 0, 0); -} - -void SFROM_Init(CartInfo *info) -{ - GenMMC1Init(info, 256, 256, 0, 0); -} - -void SHROM_Init(CartInfo *info) -{ - GenMMC1Init(info, 256, 256, 0, 0); -} - -/* End unknown */ -/* */ -/* */ - -void SNROM_Init(CartInfo *info) -{ - GenMMC1Init(info, 256, 0, 8, info->battery); -} - -void SOROM_Init(CartInfo *info) -{ - GenMMC1Init(info, 256, 0, 16, info->battery); -} - - diff --git a/boards/mmc3.c b/boards/mmc3.c deleted file mode 100644 index 63459101..00000000 --- a/boards/mmc3.c +++ /dev/null @@ -1,1602 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 1998 BERO - * Copyright (C) 2003 Xodnizel - * Mapper 12 code Copyright (C) 2003 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 - */ - -/* Code for emulating iNES mappers 4,12,44,45,47,49,52,74,114,115,116,118, - 119,148,165,205,214,215,245,249,250,254 -*/ - -#include "mapinc.h" -#include "mmc3.h" - -uint8 MMC3_cmd; -uint8 *WRAM; -uint8 *CHRRAM; -uint32 CHRRAMSize; -uint8 EXPREGS[8]; /* For bootleg games, mostly. */ - -static uint8 A000B,A001B; -static uint8 DRegBuf[8]; - -#undef IRQCount -#undef IRQLatch -#undef IRQa -uint8 IRQCount,IRQLatch,IRQa; -uint8 IRQReload; - -static SFORMAT MMC3_StateRegs[]= -{ - {DRegBuf, 8, "REGS"}, - {&MMC3_cmd, 1, "CMD"}, - {&A000B, 1, "A000"}, - {&A001B, 1, "A001"}, - {&IRQReload, 1, "IRQR"}, - {&IRQCount, 1, "IRQC"}, - {&IRQLatch, 1, "IRQL"}, - {&IRQa, 1, "IRQA"}, - {0} -}; - -static int mmc3opts=0; -static int wrams; -static int isRevB=1; - -void (*pwrap)(uint32 A, uint8 V); -void (*cwrap)(uint32 A, uint8 V); -void (*mwrap)(uint8 V); - -void GenMMC3Power(void); -void FixMMC3PRG(int V); -void FixMMC3CHR(int V); - -void GenMMC3_Init(CartInfo *info, int prg, int chr, int wram, int battery); - -// ---------------------------------------------------------------------- -// ------------------------- Generic MM3 Code --------------------------- -// ---------------------------------------------------------------------- - -void FixMMC3PRG(int V) -{ - if(V&0x40) - { - pwrap(0xC000,DRegBuf[6]); - pwrap(0x8000,~1); - } - else - { - pwrap(0x8000,DRegBuf[6]); - pwrap(0xC000,~1); - } - pwrap(0xA000,DRegBuf[7]); - pwrap(0xE000,~0); -} - -void FixMMC3CHR(int V) -{ - int cbase=(V&0x80)<<5; - - cwrap((cbase^0x000),DRegBuf[0]&(~1)); - cwrap((cbase^0x400),DRegBuf[0]|1); - cwrap((cbase^0x800),DRegBuf[1]&(~1)); - cwrap((cbase^0xC00),DRegBuf[1]|1); - - cwrap(cbase^0x1000,DRegBuf[2]); - cwrap(cbase^0x1400,DRegBuf[3]); - cwrap(cbase^0x1800,DRegBuf[4]); - cwrap(cbase^0x1c00,DRegBuf[5]); -} - -void MMC3RegReset(void) -{ - IRQCount=IRQLatch=IRQa=MMC3_cmd=0; - - DRegBuf[0]=0; - DRegBuf[1]=2; - DRegBuf[2]=4; - DRegBuf[3]=5; - DRegBuf[4]=6; - DRegBuf[5]=7; - DRegBuf[6]=0; - DRegBuf[7]=1; - - FixMMC3PRG(0); - FixMMC3CHR(0); -} - -DECLFW(MMC3_CMDWrite) -{ -// FCEU_printf("%04x:%04x\n",A,V); - switch(A&0xE001) - { - case 0x8000: - if((V&0x40) != (MMC3_cmd&0x40)) - FixMMC3PRG(V); - if((V&0x80) != (MMC3_cmd&0x80)) - FixMMC3CHR(V); - MMC3_cmd = V; - break; - case 0x8001: - { - int cbase=(MMC3_cmd&0x80)<<5; - DRegBuf[MMC3_cmd&0x7]=V; - switch(MMC3_cmd&0x07) - { - case 0: cwrap((cbase^0x000),V&(~1)); - cwrap((cbase^0x400),V|1); - break; - case 1: cwrap((cbase^0x800),V&(~1)); - cwrap((cbase^0xC00),V|1); - break; - case 2: cwrap(cbase^0x1000,V); - break; - case 3: cwrap(cbase^0x1400,V); - break; - case 4: cwrap(cbase^0x1800,V); - break; - case 5: cwrap(cbase^0x1C00,V); - break; - case 6: - if(MMC3_cmd&0x40) - pwrap(0xC000,V); - else - pwrap(0x8000,V); - break; - case 7: - pwrap(0xA000,V); - break; - } - } - break; - case 0xA000: - if(mwrap) mwrap(V&1); - break; - case 0xA001: - A001B=V; - Write_IRQFM(0x4017,0x40); - break; - } -} - -DECLFW(MMC3_IRQWrite) -{ -// FCEU_printf("%04x:%04x\n",A,V); - switch(A&0xE001) - { - case 0xC000:IRQLatch=V;break; - case 0xC001:IRQReload=1;break; - case 0xE000:X6502_IRQEnd(FCEU_IQEXT);IRQa=0;break; - case 0xE001:IRQa=1;break; - } -} - -static void ClockMMC3Counter(void) -{ - int count = IRQCount; - if(!count || IRQReload) - { - IRQCount = IRQLatch; - IRQReload = 0; - } - else - IRQCount--; - if((count|isRevB) && !IRQCount) - { - if(IRQa) - { - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -static void MMC3_hb(void) -{ - ClockMMC3Counter(); -} - -static void MMC3_hb_KickMasterHack(void) -{ - if(scanline==238) ClockMMC3Counter(); - ClockMMC3Counter(); -} - -static void MMC3_hb_PALStarWarsHack(void) -{ - if(scanline==240) ClockMMC3Counter(); - ClockMMC3Counter(); -} - -void GenMMC3Restore(int version) -{ - if(mwrap) mwrap(A000B&1); - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void GENCWRAP(uint32 A, uint8 V) -{ - if(!UNIFchrrama) setchr1(A,V); -} - -static void GENPWRAP(uint32 A, uint8 V) -{ - setprg8(A,V&0x3F); -} - -static void GENMWRAP(uint8 V) -{ - A000B=V; - setmirror(V^1); -} - -static void GENNOMWRAP(uint8 V) -{ - A000B=V; -} - -static DECLFW(MBWRAM) -{ - WRAM[A-0x6000]=V; -} - -static DECLFR(MAWRAM) -{ - return(WRAM[A-0x6000]); -} - -static DECLFW(MBWRAMMMC6) -{ - WRAM[A&0x3ff]=V; -} - -static DECLFR(MAWRAMMMC6) -{ - return(WRAM[A&0x3ff]); -} - -void GenMMC3Power(void) -{ - if(UNIFchrrama) setchr8(0); - - SetWriteHandler(0x8000,0xBFFF,MMC3_CMDWrite); - SetWriteHandler(0xC000,0xFFFF,MMC3_IRQWrite); - SetReadHandler(0x8000,0xFFFF,CartBR); - A001B=A000B=0; - setmirror(1); - if(mmc3opts&1) - { - if(wrams==1024) - { - FCEU_CheatAddRAM(1,0x7000,WRAM); - SetReadHandler(0x7000,0x7FFF,MAWRAMMMC6); - SetWriteHandler(0x7000,0x7FFF,MBWRAMMMC6); - } - else - { - FCEU_CheatAddRAM(wrams>>10,0x6000,WRAM); - SetReadHandler(0x6000,0x6000+wrams-1,MAWRAM); - SetWriteHandler(0x6000,0x6000+wrams-1,MBWRAM); - } - if(!(mmc3opts&2)) - FCEU_dwmemset(WRAM,0,wrams); - } - MMC3RegReset(); - if(CHRRAM) - FCEU_dwmemset(CHRRAM,0,CHRRAMSize); -} - -static void GenMMC3Close(void) -{ - if(CHRRAM) - FCEU_gfree(CHRRAM); - if(WRAM) - FCEU_gfree(WRAM); - CHRRAM=WRAM=NULL; -} - -//static uint16 _a12; -//static void FP_FASTAPASS(1) MMC3_PPU(uint32 A) -//{ -// if(A&0x2000)return; -// if((!_a12)&&(A&0x1000)) -// ClockMMC3Counter(); -// _a12=A&0x1000; -//} - -void GenMMC3_Init(CartInfo *info, int prg, int chr, int wram, int battery) -{ - pwrap=GENPWRAP; - cwrap=GENCWRAP; - mwrap=GENMWRAP; - - wrams=wram<<10; - - PRGmask8[0]&=(prg>>13)-1; - CHRmask1[0]&=(chr>>10)-1; - CHRmask2[0]&=(chr>>11)-1; - - if(wram) - { - mmc3opts|=1; - WRAM=(uint8*)FCEU_gmalloc(wrams); - AddExState(WRAM, wrams, 0, "WRAM"); - } - - if(battery) - { - mmc3opts|=2; - info->SaveGame[0]=WRAM; - info->SaveGameLen[0]=wrams; - } - -// if(!chr) // duplicated CHR RAM set up -// { -// CHRRAM=(uint8*)FCEU_gmalloc(8192); -// CHRRAMSize=8192; -// SetupCartCHRMapping(0, CHRRAM, 8192, 1); -// AddExState(CHRRAM, 8192, 0, "CHRR"); -// } - - AddExState(MMC3_StateRegs, ~0, 0, 0); - - info->Power=GenMMC3Power; - info->Reset=MMC3RegReset; - info->Close=GenMMC3Close; - - if(info->CRC32 == 0x5104833e) // Kick Master - GameHBIRQHook = MMC3_hb_KickMasterHack; - else if(info->CRC32 == 0x5a6860f1 || info->CRC32 == 0xae280e20) // Shougi Meikan '92/'93 - GameHBIRQHook = MMC3_hb_KickMasterHack; - else if(info->CRC32 == 0xfcd772eb) // PAL Star Wars, similar problem as Kick Master. - GameHBIRQHook = MMC3_hb_PALStarWarsHack; - else - GameHBIRQHook=MMC3_hb; -// PPU_hook=MMC3_PPU; - GameStateRestore=GenMMC3Restore; -} - -// ---------------------------------------------------------------------- -// -------------------------- MMC3 Based Code --------------------------- -// ---------------------------------------------------------------------- - -// ---------------------------- Mapper 4 -------------------------------- - -static int hackm4=0;/* For Karnov, maybe others. BLAH. Stupid iNES format.*/ - -static void M4Power(void) -{ - GenMMC3Power(); - A000B=(hackm4^1)&1; - setmirror(hackm4); -} - -void Mapper4_Init(CartInfo *info) -{ - int ws=8; - - if((info->CRC32==0x93991433 || info->CRC32==0xaf65aa84)) - { - FCEU_printf("Low-G-Man can not work normally in the iNES format.\nThis game has been recognized by its CRC32 value, and the appropriate changes will be made so it will run.\nIf you wish to hack this game, you should use the UNIF format for your hack.\n\n"); - ws=0; - } - GenMMC3_Init(info,512,256,ws,info->battery); - info->Power=M4Power; - hackm4=info->mirror; -} - -// ---------------------------- Mapper 12 ------------------------------- - -static void M12CW(uint32 A, uint8 V) -{ - setchr1(A,(EXPREGS[(A&0x1000)>>12]<<8)+V); -} - -static DECLFW(M12Write) -{ - EXPREGS[0]=V&0x01; - EXPREGS[1]=(V&0x10)>>4; -} - -static void M12Power(void) -{ - EXPREGS[0]=EXPREGS[1]=0; - GenMMC3Power(); - SetWriteHandler(0x4100,0x5FFF,M12Write); -} - -void Mapper12_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M12CW; - info->Power=M12Power; - AddExState(EXPREGS, 2, 0, "EXPR"); -} - -// ---------------------------- Mapper 37 ------------------------------- - -static void M37PW(uint32 A, uint8 V) -{ - if(EXPREGS[0]!=2) - V&=0x7; - else - V&=0xF; - V|=EXPREGS[0]<<3; - setprg8(A,V); -} - -static void M37CW(uint32 A, uint8 V) -{ - uint32 NV=V; - NV&=0x7F; - NV|=EXPREGS[0]<<6; - setchr1(A,NV); -} - -static DECLFW(M37Write) -{ - EXPREGS[0]=(V&6)>>1; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void M37Reset(void) -{ - EXPREGS[0]=0; - MMC3RegReset(); -} - -static void M37Power(void) -{ - EXPREGS[0]=0; - GenMMC3Power(); - SetWriteHandler(0x6000,0x7FFF,M37Write); -} - -void Mapper37_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - pwrap=M37PW; - cwrap=M37CW; - info->Power=M37Power; - info->Reset=M37Reset; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 44 ------------------------------- - -static void M44PW(uint32 A, uint8 V) -{ - uint32 NV=V; - if(EXPREGS[0]>=6) NV&=0x1F; - else NV&=0x0F; - NV|=EXPREGS[0]<<4; - setprg8(A,NV); -} - -static void M44CW(uint32 A, uint8 V) -{ - uint32 NV=V; - if(EXPREGS[0]<6) NV&=0x7F; - NV|=EXPREGS[0]<<7; - setchr1(A,NV); -} - -static DECLFW(M44Write) -{ - if(A&1) - { - EXPREGS[0]=V&7; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); - } - else - MMC3_CMDWrite(A,V); -} - -static void M44Power(void) -{ - EXPREGS[0]=0; - GenMMC3Power(); - SetWriteHandler(0xA000,0xBFFF,M44Write); -} - -void Mapper44_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M44CW; - pwrap=M44PW; - info->Power=M44Power; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 45 ------------------------------- - -static void M45CW(uint32 A, uint8 V) -{ - if(!UNIFchrrama) - { - uint32 NV=V; - if(EXPREGS[2]&8) - NV&=(1<<((EXPREGS[2]&7)+1))-1; -// else -// NV&=0; - NV|=EXPREGS[0]|((EXPREGS[2]&0xF0)<<4); - setchr1(A,NV); - } -} - -static void M45PW(uint32 A, uint8 V) -{ - V&=(EXPREGS[3]&0x3F)^0x3F; - V|=EXPREGS[1]; - setprg8(A,V); -} - -static DECLFW(M45Write) -{ - if(EXPREGS[3]&0x40) - { - WRAM[A-0x6000]=V; - return; - } - EXPREGS[EXPREGS[4]]=V; - EXPREGS[4]=(EXPREGS[4]+1)&3; - if(!EXPREGS[4]) - { - FCEU_printf("CHROR %02x, PRGOR %02x, CHRAND %02x, PRGAND %02x\n",EXPREGS[0],EXPREGS[1],EXPREGS[2],EXPREGS[3]); - FCEU_printf("CHR0 %03x, CHR1 %03x, PRG0 %03x, PRG1 %03x\n", - (0x00&((1<<((EXPREGS[2]&7)+1))-1))|(EXPREGS[0]|((EXPREGS[2]&0xF0)<<4)), - (0xFF&((1<<((EXPREGS[2]&7)+1))-1))|(EXPREGS[0]|((EXPREGS[2]&0xF0)<<4)), - (0x00&((EXPREGS[3]&0x3F)^0x3F))|(EXPREGS[1]), - (0xFF&((EXPREGS[3]&0x3F)^0x3F))|(EXPREGS[1])); - } - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void M45Reset(void) -{ - EXPREGS[0]=EXPREGS[1]=EXPREGS[2]=EXPREGS[3]=EXPREGS[4]=0; - MMC3RegReset(); -} - -static void M45Power(void) -{ - setchr8(0); - GenMMC3Power(); - SetWriteHandler(0x6000,0x7FFF,M45Write); -} - -void Mapper45_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M45CW; - pwrap=M45PW; - info->Reset=M45Reset; - info->Power=M45Power; - AddExState(EXPREGS, 5, 0, "EXPR"); -} - -// ---------------------------- Mapper 47 ------------------------------- - -static void M47PW(uint32 A, uint8 V) -{ - V&=0xF; - V|=EXPREGS[0]<<4; - setprg8(A,V); -} - -static void M47CW(uint32 A, uint8 V) -{ - uint32 NV=V; - NV&=0x7F; - NV|=EXPREGS[0]<<7; - setchr1(A,NV); -} - -static DECLFW(M47Write) -{ - EXPREGS[0]=V&1; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void M47Power(void) -{ - EXPREGS[0]=0; - GenMMC3Power(); - SetWriteHandler(0x6000,0x7FFF,M47Write); -// SetReadHandler(0x6000,0x7FFF,0); -} - -void Mapper47_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - pwrap=M47PW; - cwrap=M47CW; - info->Power=M47Power; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 49 ------------------------------- - -static void M49PW(uint32 A, uint8 V) -{ - if(EXPREGS[0]&1) - { - V&=0xF; - V|=(EXPREGS[0]&0xC0)>>2; - setprg8(A,V); - } - else - setprg32(0x8000,(EXPREGS[0]>>4)&3); -} - -static void M49CW(uint32 A, uint8 V) -{ - uint32 NV=V; - NV&=0x7F; - NV|=(EXPREGS[0]&0xC0)<<1; - setchr1(A,NV); -} - -static DECLFW(M49Write) -{ - if(A001B&0x80) - { - EXPREGS[0]=V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); - } -} - -static void M49Reset(void) -{ - EXPREGS[0]=0; - MMC3RegReset(); -} - -static void M49Power(void) -{ - M49Reset(); - GenMMC3Power(); - SetWriteHandler(0x6000,0x7FFF,M49Write); - SetReadHandler(0x6000,0x7FFF,0); -} - -void Mapper49_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 0, 0); - cwrap=M49CW; - pwrap=M49PW; - info->Reset=M49Reset; - info->Power=M49Power; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 52 ------------------------------- - -static void M52PW(uint32 A, uint8 V) -{ - uint32 NV=V; - NV&=0x1F^((EXPREGS[0]&8)<<1); - NV|=((EXPREGS[0]&6)|((EXPREGS[0]>>3)&EXPREGS[0]&1))<<4; - setprg8(A,NV); -} - -static void M52CW(uint32 A, uint8 V) -{ - uint32 NV=V; - NV&=0xFF^((EXPREGS[0]&0x40)<<1); - NV|=(((EXPREGS[0]>>3)&4)|((EXPREGS[0]>>1)&2)|((EXPREGS[0]>>6)&(EXPREGS[0]>>4)&1))<<7; - setchr1(A,NV); -} - -static DECLFW(M52Write) -{ - if(EXPREGS[1]) - { - WRAM[A-0x6000]=V; - return; - } - EXPREGS[1]=1; - EXPREGS[0]=V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void M52Reset(void) -{ - EXPREGS[0]=EXPREGS[1]=0; - MMC3RegReset(); -} - -static void M52Power(void) -{ - M52Reset(); - GenMMC3Power(); - SetWriteHandler(0x6000,0x7FFF,M52Write); -} - -void Mapper52_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M52CW; - pwrap=M52PW; - info->Reset=M52Reset; - info->Power=M52Power; - AddExState(EXPREGS, 2, 0, "EXPR"); -} - -// ---------------------------- Mapper 74 ------------------------------- - -static void M74CW(uint32 A, uint8 V) -{ - if((V==8)||(V==9)) //Di 4 Ci - Ji Qi Ren Dai Zhan (As).nes, Ji Jia Zhan Shi (As).nes - setchr1r(0x10,A,V); - else - setchr1r(0,A,V); -} - -void Mapper74_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M74CW; - CHRRAMSize=2048; - CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); -} - -// ---------------------------- Mapper 114 ------------------------------ - -static uint8 cmdin; -uint8 m114_perm[8] = {0, 3, 1, 5, 6, 7, 2, 4}; - -static void M114PWRAP(uint32 A, uint8 V) -{ - if(EXPREGS[0]&0x80) - { - setprg16(0x8000,EXPREGS[0]&0xF); - setprg16(0xC000,EXPREGS[0]&0xF); - } - else - setprg8(A,V&0x3F); -} - -static DECLFW(M114Write) -{ - if(A==0xE003) - { - IRQa=1; - IRQLatch=V; - IRQReload=1; - } - else if(A==0xE002) - { - IRQa=0; - X6502_IRQEnd(FCEU_IQEXT); - } - else switch(A&0xE000) - { - case 0x8000: setmirror((V&1)^1); break; - case 0xA000: MMC3_CMDWrite(0x8000,(V&0xC0)|(m114_perm[V&7])); cmdin=1; break; - case 0xC000: if(!cmdin) break; - MMC3_CMDWrite(0x8001,V); - cmdin=0; - break; - } -} - -static DECLFW(M114ExWrite) -{ - if(A<=0x7FFF) - { - EXPREGS[0]=V; - FixMMC3PRG(MMC3_cmd); - } -} - -static void M114Power(void) -{ - GenMMC3Power(); - SetWriteHandler(0x8000,0xFFFF,M114Write); - SetWriteHandler(0x5000,0x7FFF,M114ExWrite); -} - -static void M114Reset(void) -{ - EXPREGS[0]=0; - MMC3RegReset(); -} - -void Mapper114_Init(CartInfo *info) -{ - GenMMC3_Init(info, 256, 256, 0, 0); - pwrap=M114PWRAP; - info->Power=M114Power; - info->Reset=M114Reset; - AddExState(EXPREGS, 1, 0, "EXPR"); - AddExState(&cmdin, 1, 0, "CMDIN"); -} - -// ---------------------------- Mapper 115 ------------------------------ - -static void M115PW(uint32 A, uint8 V) -{ - if(EXPREGS[0]&0x80) - setprg32(0x8000,(EXPREGS[0]&7)>>1); - else - setprg8(A,V); -} - -static void M115CW(uint32 A, uint8 V) -{ - setchr1(A,(uint32)V|((EXPREGS[1]&1)<<8)); -} - -static DECLFW(M115Write) -{ - if(A==0x6000) - EXPREGS[0]=V; - else if(A==0x6001) - EXPREGS[1]=V; - FixMMC3PRG(MMC3_cmd); -} - -static void M115Power(void) -{ - GenMMC3Power(); - SetWriteHandler(0x4100,0x7FFF,M115Write); - SetReadHandler(0x4100,0x7FFF,0); -} - -void Mapper115_Init(CartInfo *info) -{ - GenMMC3_Init(info, 128, 512, 0, 0); - cwrap=M115CW; - pwrap=M115PW; - info->Power=M115Power; - AddExState(EXPREGS, 2, 0, "EXPR"); -} - -// ---------------------------- Mapper 116 ------------------------------ - -static void M116CW(uint32 A, uint8 V) -{ -// setchr1(A,V|((EXPREGS[0]&0x4)<<6)); - if(EXPREGS[0]&2) - setchr8r(0x10,0); - else - setchr1(A,V); -} - -static DECLFW(M116Write) -{ - EXPREGS[0]=V; - FixMMC3CHR(MMC3_cmd); -} - -static void M116Power(void) -{ - GenMMC3Power(); - SetWriteHandler(0x4100,0x4100,M116Write); -} - -void Mapper116_Init(CartInfo *info) -{ - GenMMC3_Init(info, 128, 512, 0, 0); - cwrap=M116CW; - info->Power=M116Power; - CHRRAM = (uint8*)FCEU_gmalloc(8192); - SetupCartCHRMapping(0x10, CHRRAM, 8192, 1); - AddExState(EXPREGS, 4, 0, "EXPR"); -} - -// ---------------------------- Mapper 118 ------------------------------ - -static uint8 PPUCHRBus; -static uint8 TKSMIR[8]; - -static void FP_FASTAPASS(1) TKSPPU(uint32 A) -{ - A&=0x1FFF; - A>>=10; - PPUCHRBus=A; - setmirror(MI_0+TKSMIR[A]); -} - -static void TKSWRAP(uint32 A, uint8 V) -{ - TKSMIR[A>>10]=V>>7; - setchr1(A,V&0x7F); - if(PPUCHRBus==(A>>10)) - setmirror(MI_0+(V>>7)); -} - -void Mapper118_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=TKSWRAP; - mwrap=GENNOMWRAP; - PPU_hook=TKSPPU; - AddExState(&PPUCHRBus, 1, 0, "PPUC"); -} - -// ---------------------------- Mapper 119 ------------------------------ - -static void TQWRAP(uint32 A, uint8 V) -{ - setchr1r((V&0x40)>>2,A,V&0x3F); -} - -void Mapper119_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 64, 0, 0); - cwrap=TQWRAP; - CHRRAMSize=8192; - CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); -} - -// ---------------------------- Mapper 165 ------------------------------ - -static void M165CW(uint32 A, uint8 V) -{ - if(V==0) - setchr4r(0x10,A,0); - else - setchr4(A,V>>2); -} - -static void M165PPUFD(void) -{ - if(EXPREGS[0]==0xFD) - { - M165CW(0x0000,DRegBuf[0]); - M165CW(0x1000,DRegBuf[2]); - } -} - -static void M165PPUFE(void) -{ - if(EXPREGS[0]==0xFE) - { - M165CW(0x0000,DRegBuf[1]); - M165CW(0x1000,DRegBuf[4]); - } -} - -static void M165CWM(uint32 A, uint8 V) -{ - if(((MMC3_cmd&0x7)==0)||((MMC3_cmd&0x7)==2)) - M165PPUFD(); - if(((MMC3_cmd&0x7)==1)||((MMC3_cmd&0x7)==4)) - M165PPUFE(); -} - -static void FP_FASTAPASS(1) M165PPU(uint32 A) -{ - if((A&0x1FF0)==0x1FD0) - { - EXPREGS[0]=0xFD; - M165PPUFD(); - } else if((A&0x1FF0)==0x1FE0) - { - EXPREGS[0]=0xFE; - M165PPUFE(); - } -} - -static void M165Power(void) -{ - EXPREGS[0]=0xFD; - GenMMC3Power(); -} - -void Mapper165_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 128, 8, info->battery); - cwrap=M165CWM; - PPU_hook=M165PPU; - info->Power=M165Power; - CHRRAMSize = 4096; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); - AddExState(EXPREGS, 4, 0, "EXPR"); -} - -// ---------------------------- Mapper 182 ------------------------------ -// òàáëèöà ïåðìóòàöè àíàëîãè÷íà 114 ìàïïåðó, ðåãèñòðû ìàïïåðà ãîðàçäî ñëîæíåå, -// ÷åì èñïîëüçóþòñÿ çäåñü, õîòÿ âñå ïðåêðàñíî ðàáîòàåò. - -//static uint8 m182_perm[8] = {0, 3, 1, 5, 6, 7, 2, 4}; -static DECLFW(M182Write) -{ - switch(A&0xF003) - { - case 0x8001: setmirror((V&1)^1); break; - case 0xA000: MMC3_CMDWrite(0x8000,m114_perm[V&7]); break; - case 0xC000: MMC3_CMDWrite(0x8001,V); break; - case 0xE003: if(V) - { - IRQLatch=V; - IRQReload=1; - IRQa=1; - } - X6502_IRQEnd(FCEU_IQEXT); - break; - } -} - -static void M182Power(void) -{ - GenMMC3Power(); - SetWriteHandler(0x8000,0xFFFF,M182Write); -} - -void Mapper182_Init(CartInfo *info) -{ - GenMMC3_Init(info, 256, 256, 0, 0); - info->Power=M182Power; -} - -// ---------------------------- Mapper 191 ------------------------------ - -static void M191CW(uint32 A, uint8 V) -{ - setchr1r((V&0x80)>>3,A,V); -} - -void Mapper191_Init(CartInfo *info) -{ - GenMMC3_Init(info, 256, 256, 8, info->battery); - cwrap=M191CW; - CHRRAMSize=2048; - CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); -} - -// ---------------------------- Mapper 192 ------------------------------- - -static void M192CW(uint32 A, uint8 V) -{ - if((V==8)||(V==9)||(V==0xA)||(V==0xB)) //Ying Lie Qun Xia Zhuan (Chinese), - setchr1r(0x10,A,V); - else - setchr1r(0,A,V); -} - -void Mapper192_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M192CW; - CHRRAMSize=4096; - CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); -} - -// ---------------------------- Mapper 194 ------------------------------- - -static void M194CW(uint32 A, uint8 V) -{ - if(V<=1) //Dai-2-Ji - Super Robot Taisen (As).nes - setchr1r(0x10,A,V); - else - setchr1r(0,A,V); -} - -void Mapper194_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M194CW; - CHRRAMSize=2048; - CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); -} - -// ---------------------------- Mapper 198 ------------------------------- - -static uint8 *wramtw; -static uint16 wramsize; -static void M198CW(uint32 A, uint8 V) -{ - if(V<=3) // Crystalis (c).nes, Captain Tsubasa Vol 2 - Super Striker (C) - setchr1r(0x10,A,V); - else - setchr1r(0,A,V); -} - -static void M198Power(void) -{ - GenMMC3Power(); - setprg4r(0x10,0x5000,0); - SetWriteHandler(0x5000,0x5fff,CartBW); - SetReadHandler(0x5000,0x5fff,CartBR); -} - -static void M198Close(void) -{ - if(wramtw) - FCEU_gfree(wramtw); - wramtw=NULL; -} - -void Mapper198_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M198CW; - info->Power=M198Power; - info->Close=M198Close; - CHRRAMSize=4096; - CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - wramsize=4096; - wramtw=(uint8*)FCEU_gmalloc(wramsize); - SetupCartPRGMapping(0x10, wramtw, wramsize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); - AddExState(wramtw, wramsize, 0, "WRAMTW"); -} - -// ---------------------------- Mapper 199 ------------------------------- - -static uint8 *wramtw; -static uint16 wramsize; -static void M199PW(uint32 A, uint8 V) -{ - if(V>=0x50) - setprg8(A,V&0x4F); - else - setprg8(A,V); -} - -void Mapper199_Init(CartInfo *info) -{ - GenMMC3_Init(info, 1024, 256, 8, info->battery); - pwrap=M199PW; - info->Power=M198Power; - info->Close=M198Close; - wramsize=4096; - wramtw=(uint8*)FCEU_gmalloc(wramsize); - SetupCartPRGMapping(0x10, wramtw, wramsize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); - AddExState(wramtw, wramsize, 0, "WRAMTW"); -} - -// ---------------------------- Mapper 205 ------------------------------ - -static void M205PW(uint32 A, uint8 V) -{ - if(EXPREGS[0]&2) - setprg8(A,(V&0x0f)|((EXPREGS[0]&3)<<4)); - else - setprg8(A,(V&0x1f)|((EXPREGS[0]&3)<<4)); -} - -static void M205CW(uint32 A, uint8 V) -{ - setchr1(A,V|((EXPREGS[0]&3)<<7)); -} - -static DECLFW(M205Write) -{ - if((A&0x6800)==0x6800) EXPREGS[0]= V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void M205Reset(void) -{ - EXPREGS[0]=0; - MMC3RegReset(); -} - -static void M205Power(void) -{ - GenMMC3Power(); - SetWriteHandler(0x4020,0x7FFF,M205Write); -} - -void Mapper205_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, 0); - pwrap=M205PW; - cwrap=M205CW; - info->Power=M205Power; - info->Reset=M205Reset; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 215 ------------------------------ - -static uint8 m215_perm[8] = {0, 2, 5, 3, 6, 1, 7, 4}; - -static void M215CW(uint32 A, uint8 V) -{ - if(EXPREGS[1]&0x04) - setchr1(A,V|0x100); - else - setchr1(A,(V&0x7F)|((EXPREGS[1]&0x10)<<3)); -} - -static void M215PW(uint32 A, uint8 V) -{ - if(EXPREGS[0]&0x80) - { - setprg16(0x8000,(EXPREGS[0]&0x0F)|(EXPREGS[1]&0x10)); - setprg16(0xC000,(EXPREGS[0]&0x0F)|(EXPREGS[1]&0x10)); - } - else if(EXPREGS[1]&0x08) - setprg8(A,(V&0x1F)|0x20); - else - setprg8(A,(V&0x0F)|(EXPREGS[1]&0x10)); -} - -static DECLFW(M215Write) -{ - if(!(EXPREGS[2])) - { - if(A >= 0xc000) - MMC3_IRQWrite(A,V); - else - MMC3_CMDWrite(A,V); - } - else switch(A&0xE001) - { - case 0xC001: IRQLatch=V; break; - case 0xA001: IRQReload=1; break; - case 0xE001: IRQa=1; break; - case 0xE000: X6502_IRQEnd(FCEU_IQEXT); IRQa=0; break; - case 0xC000: setmirror(((V|(V>>7))&1)^1); break; - case 0xA000: MMC3_CMDWrite(0x8000,(V&0xC0)|(m215_perm[V&7])); cmdin=1; break; - case 0x8001: if(!cmdin) break; - MMC3_CMDWrite(0x8001,V); - cmdin=0; - break; - } -} - -static DECLFW(M215ExWrite) -{ - switch(A) - { - case 0x5000: - EXPREGS[0]=V; - FixMMC3PRG(MMC3_cmd); - break; - case 0x5001: - EXPREGS[1]=V; - FixMMC3CHR(MMC3_cmd); - break; - case 0x5007: - EXPREGS[2]=V; - MMC3RegReset(); - break; - } -} - -static void M215Power(void) -{ - EXPREGS[0]=0; - EXPREGS[1]=0xFF; - EXPREGS[2]=4; - GenMMC3Power(); - SetWriteHandler(0x8000,0xFFFF,M215Write); - SetWriteHandler(0x5000,0x7FFF,M215ExWrite); -} - -void Mapper215_Init(CartInfo *info) -{ - GenMMC3_Init(info, 256, 256, 0, 0); - cwrap=M215CW; - pwrap=M215PW; - info->Power=M215Power; - AddExState(EXPREGS, 3, 0, "EXPR"); - AddExState(&cmdin, 1, 0, "CMDIN"); -} - -// ---------------------------- Mapper 217 ------------------------------ - -static uint8 m217_perm[8] = {0, 6, 3, 7, 5, 2, 4, 1}; - -static void M217CW(uint32 A, uint8 V) -{ - if(EXPREGS[1]&0x08) - setchr1(A,V|((EXPREGS[1]&3)<<8)); - else - setchr1(A,(V&0x7F)|((EXPREGS[1]&3)<<8)|((EXPREGS[1]&0x10)<<3)); -} - -static void M217PW(uint32 A, uint8 V) -{ - if(EXPREGS[0]&0x80) - { - setprg16(0x8000,(EXPREGS[0]&0x0F)|((EXPREGS[1]&3)<<4)); - setprg16(0xC000,(EXPREGS[0]&0x0F)|((EXPREGS[1]&3)<<4)); - } - else if(EXPREGS[1]&0x08) - setprg8(A,(V&0x1F)|((EXPREGS[1]&3)<<5)); - else - setprg8(A,(V&0x0F)|((EXPREGS[1]&3)<<5)|(EXPREGS[1]&0x10)); -} - -static DECLFW(M217Write) -{ - if(!EXPREGS[2]) - { - if(A >= 0xc000) - MMC3_IRQWrite(A, V); - else - MMC3_CMDWrite(A,V); - } - else switch(A&0xE001) - { - case 0x8000: IRQCount=V; break; - case 0xE000: X6502_IRQEnd(FCEU_IQEXT);IRQa=0; break; - case 0xC001: IRQa=1; break; - case 0xA001: setmirror((V&1)^1); break; - case 0x8001: MMC3_CMDWrite(0x8000,(V&0xC0)|(m217_perm[V&7])); cmdin=1; break; - case 0xA000: if(!cmdin) break; - MMC3_CMDWrite(0x8001,V); - cmdin=0; - break; - } -} - -static DECLFW(M217ExWrite) -{ - switch(A) - { - case 0x5000: - EXPREGS[0]=V; - FixMMC3PRG(MMC3_cmd); - break; - case 0x5001: - EXPREGS[1]=V; - FixMMC3PRG(MMC3_cmd); - break; - case 0x5007: - EXPREGS[2]=V; - break; - } -} - -static void M217Power(void) -{ - EXPREGS[0]=0; - EXPREGS[1]=0xFF; - EXPREGS[2]=3; - GenMMC3Power(); - SetWriteHandler(0x8000,0xFFFF,M217Write); - SetWriteHandler(0x5000,0x7FFF,M217ExWrite); -} - -void Mapper217_Init(CartInfo *info) -{ - GenMMC3_Init(info, 256, 256, 0, 0); - cwrap=M217CW; - pwrap=M217PW; - info->Power=M217Power; - AddExState(EXPREGS, 3, 0, "EXPR"); - AddExState(&cmdin, 1, 0, "CMDIN"); -} - -// ---------------------------- Mapper 245 ------------------------------ - -static void M245CW(uint32 A, uint8 V) -{ - setchr1(A,V&7); - EXPREGS[0]=V; - FixMMC3PRG(MMC3_cmd); -} - -static void M245PW(uint32 A, uint8 V) -{ - setprg8(A,(V&0x3F)|((EXPREGS[0]&2)<<5)); -} - -static void M245Power(void) -{ - EXPREGS[0]=0; - GenMMC3Power(); -} - -void Mapper245_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M245CW; - pwrap=M245PW; - info->Power=M245Power; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 249 ------------------------------ - -static void M249PW(uint32 A, uint8 V) -{ - if(EXPREGS[0]&0x2) - { - if(V<0x20) - V=(V&1)|((V>>3)&2)|((V>>1)&4)|((V<<2)&8)|((V<<2)&0x10); - else - { - V-=0x20; - V=(V&3)|((V>>1)&4)|((V>>4)&8)|((V>>2)&0x10)|((V<<3)&0x20)|((V<<2)&0xC0); - } - } - setprg8(A,V); -} - -static void M249CW(uint32 A, uint8 V) -{ - if(EXPREGS[0]&0x2) - V=(V&3)|((V>>1)&4)|((V>>4)&8)|((V>>2)&0x10)|((V<<3)&0x20)|((V<<2)&0xC0); - setchr1(A,V); -} - -static DECLFW(M249Write) -{ - EXPREGS[0]=V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void M249Power(void) -{ - EXPREGS[0]=0; - GenMMC3Power(); - SetWriteHandler(0x5000,0x5000,M249Write); -} - -void Mapper249_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M249CW; - pwrap=M249PW; - info->Power=M249Power; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 250 ------------------------------ - -static DECLFW(M250Write) -{ - MMC3_CMDWrite((A&0xE000)|((A&0x400)>>10),A&0xFF); -} - -static DECLFW(M250IRQWrite) -{ - MMC3_IRQWrite((A&0xE000)|((A&0x400)>>10),A&0xFF); -} - -static void M250_Power(void) -{ - GenMMC3Power(); - SetWriteHandler(0x8000,0xBFFF,M250Write); - SetWriteHandler(0xC000,0xFFFF,M250IRQWrite); -} - -void Mapper250_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - info->Power=M250_Power; -} - -// ---------------------------- Mapper 254 ------------------------------ - -static DECLFR(MR254WRAM) -{ - if(EXPREGS[0]) - return WRAM[A-0x6000]; - else - return WRAM[A-0x6000]^EXPREGS[1]; -} - -static DECLFW(M254Write) -{ - switch (A) { - case 0x8000: EXPREGS[0]=0xff; - break; - case 0xA001: EXPREGS[1]=V; - } - MMC3_CMDWrite(A,V); -} - -static void M254_Power(void) -{ - GenMMC3Power(); - SetWriteHandler(0x8000,0xBFFF,M254Write); - SetReadHandler(0x6000,0x7FFF,MR254WRAM); -} - -void Mapper254_Init(CartInfo *info) -{ - GenMMC3_Init(info, 128, 128, 8, info->battery); - info->Power=M254_Power; - AddExState(EXPREGS, 2, 0, "EXPR"); -} - -// ---------------------------- UNIF Boards ----------------------------- - -void TEROM_Init(CartInfo *info) -{ - GenMMC3_Init(info, 32, 32, 0, 0); -} - -void TFROM_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 64, 0, 0); -} - -void TGROM_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 0, 0, 0); -} - -void TKROM_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); -} - -void TLROM_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 0, 0); -} - -void TSROM_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, 0); -} - -void TLSROM_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, 0); - cwrap=TKSWRAP; - mwrap=GENNOMWRAP; - PPU_hook=TKSPPU; - AddExState(&PPUCHRBus, 1, 0, "PPUC"); -} - -void TKSROM_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=TKSWRAP; - mwrap=GENNOMWRAP; - PPU_hook=TKSPPU; - AddExState(&PPUCHRBus, 1, 0, "PPUC"); -} - -void TQROM_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 64, 0, 0); - cwrap=TQWRAP; - CHRRAMSize=8192; - CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); -} - -void HKROM_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 512, 1, info->battery); -} diff --git a/boards/mmc3.h b/boards/mmc3.h deleted file mode 100644 index 4e7452e3..00000000 --- a/boards/mmc3.h +++ /dev/null @@ -1,23 +0,0 @@ -extern uint8 MMC3_cmd; -extern uint8 *WRAM; -extern uint8 *CHRRAM; -extern uint8 EXPREGS[8]; -#undef IRQCount -#undef IRQLatch -#undef IRQa -extern uint8 IRQCount,IRQLatch,IRQa; -extern uint8 IRQReload; - -extern void (*pwrap)(uint32 A, uint8 V); -extern void (*cwrap)(uint32 A, uint8 V); -extern void (*mwrap)(uint8 V); - -void GenMMC3Power(void); -void GenMMC3Restore(int version); -void MMC3RegReset(void); -void FixMMC3PRG(int V); -void FixMMC3CHR(int V); -DECLFW(MMC3_CMDWrite); -DECLFW(MMC3_IRQWrite); - -void GenMMC3_Init(CartInfo *info, int prg, int chr, int wram, int battery); diff --git a/boards/mmc5.c b/boards/mmc5.c deleted file mode 100644 index ce3fc9c8..00000000 --- a/boards/mmc5.c +++ /dev/null @@ -1,834 +0,0 @@ -/* 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 - */ - -/* None of this code should use any of the iNES bank switching wrappers. */ - -#include "mapinc.h" - -static void (*sfun)(int P); -static void (*psfun)(void); - -void MMC5RunSound(int Count); -void MMC5RunSoundHQ(void); - -static INLINE void MMC5SPRVROM_BANK1(uint32 A,uint32 V) -{ - if(CHRptr[0]) - { - V&=CHRmask1[0]; - MMC5SPRVPage[(A)>>10]=&CHRptr[0][(V)<<10]-(A); - } -} - -static INLINE void MMC5BGVROM_BANK1(uint32 A,uint32 V) {if(CHRptr[0]){V&=CHRmask1[0];MMC5BGVPage[(A)>>10]=&CHRptr[0][(V)<<10]-(A);}} - -static INLINE void MMC5SPRVROM_BANK2(uint32 A,uint32 V) {if(CHRptr[0]){V&=CHRmask2[0];MMC5SPRVPage[(A)>>10]=MMC5SPRVPage[((A)>>10)+1]=&CHRptr[0][(V)<<11]-(A);}} -static INLINE void MMC5BGVROM_BANK2(uint32 A,uint32 V) {if(CHRptr[0]){V&=CHRmask2[0];MMC5BGVPage[(A)>>10]=MMC5BGVPage[((A)>>10)+1]=&CHRptr[0][(V)<<11]-(A);}} - -static INLINE void MMC5SPRVROM_BANK4(uint32 A,uint32 V) {if(CHRptr[0]){V&=CHRmask4[0];MMC5SPRVPage[(A)>>10]=MMC5SPRVPage[((A)>>10)+1]= MMC5SPRVPage[((A)>>10)+2]=MMC5SPRVPage[((A)>>10)+3]=&CHRptr[0][(V)<<12]-(A);}} -static INLINE void MMC5BGVROM_BANK4(uint32 A,uint32 V) {if(CHRptr[0]){V&=CHRmask4[0];MMC5BGVPage[(A)>>10]=MMC5BGVPage[((A)>>10)+1]=MMC5BGVPage[((A)>>10)+2]=MMC5BGVPage[((A)>>10)+3]=&CHRptr[0][(V)<<12]-(A);}} - -static INLINE void MMC5SPRVROM_BANK8(uint32 V) {if(CHRptr[0]){V&=CHRmask8[0];MMC5SPRVPage[0]=MMC5SPRVPage[1]=MMC5SPRVPage[2]=MMC5SPRVPage[3]=MMC5SPRVPage[4]=MMC5SPRVPage[5]=MMC5SPRVPage[6]=MMC5SPRVPage[7]=&CHRptr[0][(V)<<13];}} -static INLINE void MMC5BGVROM_BANK8(uint32 V) {if(CHRptr[0]){V&=CHRmask8[0];MMC5BGVPage[0]=MMC5BGVPage[1]=MMC5BGVPage[2]=MMC5BGVPage[3]=MMC5BGVPage[4]=MMC5BGVPage[5]=MMC5BGVPage[6]=MMC5BGVPage[7]=&CHRptr[0][(V)<<13];}} - -static uint8 PRGBanks[4]; -static uint8 WRAMPage; -static uint8 CHRBanksA[8], CHRBanksB[4]; -static uint8 WRAMMaskEnable[2]; -static uint8 ABMode; /* A=0, B=1 */ - -static uint8 IRQScanline,IRQEnable; -static uint8 CHRMode, NTAMirroring, NTFill, ATFill; - -static uint8 MMC5IRQR; -static uint8 MMC5LineCounter; -static uint8 mmc5psize, mmc5vsize; -static uint8 mul[2]; - -static uint8 *WRAM=NULL; -static uint8 *MMC5fill=NULL; -static uint8 *ExRAM=NULL; - -static uint8 MMC5WRAMsize; -static uint8 MMC5WRAMIndex[8]; - -static uint8 MMC5ROMWrProtect[4]; -static uint8 MMC5MemIn[5]; - -static void MMC5CHRA(void); -static void MMC5CHRB(void); - -typedef struct __cartdata { - uint32 crc32; - uint8 size; -} cartdata; - - -// ETROM seems to have 16KB of WRAM, ELROM seems to have 8KB -// EWROM seems to have 32KB of WRAM - -#define MMC5_NOCARTS 14 -cartdata MMC5CartList[MMC5_NOCARTS]= -{ - {0x9c18762b,2}, /* L'Empereur */ - {0x26533405,2}, - {0x6396b988,2}, - - {0xaca15643,2}, /* Uncharted Waters */ - {0xfe3488d1,2}, /* Dai Koukai Jidai */ - - {0x15fe6d0f,2}, /* BKAC */ - {0x39f2ce4b,2}, /* Suikoden */ - - {0x8ce478db,2}, /* Nobunaga's Ambition 2 */ - {0xeee9a682,2}, - - {0x1ced086f,2}, /* Ishin no Arashi */ - - {0xf540677b,4}, /* Nobunaga...Bushou Fuuun Roku */ - - {0x6f4e4312,4}, /* Aoki Ookami..Genchou */ - - {0xf011e490,4}, /* Romance of the 3 Kingdoms 2 */ - {0x184c2124,4}, /* Sangokushi 2 */ -}; - - -int DetectMMC5WRAMSize(uint32 crc32) -{ - int x; - for(x=0;x8KB external WRAM present. Use UNIF if you hack the ROM image.\n"); - return(MMC5CartList[x].size*8); - } - return(8); -} - -static void BuildWRAMSizeTable(void) -{ - int x; - for(x=0;x<8;x++) - { - switch(MMC5WRAMsize) - { - case 0: MMC5WRAMIndex[x]=255; break; - case 1: MMC5WRAMIndex[x]=(x>3)?255:0; break; - case 2: MMC5WRAMIndex[x]=(x&4)>>2; break; - case 4: MMC5WRAMIndex[x]=(x>3)?255:(x&3); break; - } - } -} - -static void MMC5CHRA(void) -{ - int x; - switch(mmc5vsize&3) - { - case 0: setchr8(CHRBanksA[7]); - MMC5SPRVROM_BANK8(CHRBanksA[7]); - break; - case 1: setchr4(0x0000,CHRBanksA[3]); - setchr4(0x1000,CHRBanksA[7]); - MMC5SPRVROM_BANK4(0x0000,CHRBanksA[3]); - MMC5SPRVROM_BANK4(0x1000,CHRBanksA[7]); - break; - case 2: setchr2(0x0000,CHRBanksA[1]); - setchr2(0x0800,CHRBanksA[3]); - setchr2(0x1000,CHRBanksA[5]); - setchr2(0x1800,CHRBanksA[7]); - MMC5SPRVROM_BANK2(0x0000,CHRBanksA[1]); - MMC5SPRVROM_BANK2(0x0800,CHRBanksA[3]); - MMC5SPRVROM_BANK2(0x1000,CHRBanksA[5]); - MMC5SPRVROM_BANK2(0x1800,CHRBanksA[7]); - break; - case 3: for(x=0;x<8;x++) - { - setchr1(x<<10,CHRBanksA[x]); - MMC5SPRVROM_BANK1(x<<10,CHRBanksA[x]); - } - break; - } -} - -static void MMC5CHRB(void) -{ - int x; - switch(mmc5vsize&3) - { - case 0: setchr8(CHRBanksB[3]); - MMC5BGVROM_BANK8(CHRBanksB[3]); - break; - case 1: setchr4(0x0000,CHRBanksB[3]); - setchr4(0x1000,CHRBanksB[3]); - MMC5BGVROM_BANK4(0x0000,CHRBanksB[3]); - MMC5BGVROM_BANK4(0x1000,CHRBanksB[3]); - break; - case 2: setchr2(0x0000,CHRBanksB[1]); - setchr2(0x0800,CHRBanksB[3]); - setchr2(0x1000,CHRBanksB[1]); - setchr2(0x1800,CHRBanksB[3]); - MMC5BGVROM_BANK2(0x0000,CHRBanksB[1]); - MMC5BGVROM_BANK2(0x0800,CHRBanksB[3]); - MMC5BGVROM_BANK2(0x1000,CHRBanksB[1]); - MMC5BGVROM_BANK2(0x1800,CHRBanksB[3]); - break; - case 3: for(x=0;x<8;x++) - { - setchr1(x<<10,CHRBanksB[x&3]); - MMC5BGVROM_BANK1(x<<10,CHRBanksB[x&3]); - } - break; - } -} - -static void FASTAPASS(2) MMC5WRAM(uint32 A, uint32 V) -{ - //printf("%02x\n",V); - V=MMC5WRAMIndex[V&7]; - if(V!=255) - { - setprg8r(0x10,A,V); - MMC5MemIn[(A-0x6000)>>13]=1; - } - else - MMC5MemIn[(A-0x6000)>>13]=0; -} - -static void MMC5PRG(void) -{ - int x; - switch(mmc5psize&3) - { - case 0: MMC5ROMWrProtect[0]=MMC5ROMWrProtect[1]= - MMC5ROMWrProtect[2]=MMC5ROMWrProtect[3]=1; - setprg32(0x8000,((PRGBanks[1]&0x7F)>>2)); - for(x=0;x<4;x++) - MMC5MemIn[1+x]=1; - break; - case 1: if(PRGBanks[1]&0x80) - { - MMC5ROMWrProtect[0]=MMC5ROMWrProtect[1]=1; - setprg16(0x8000,(PRGBanks[1]>>1)); - MMC5MemIn[1]=MMC5MemIn[2]=1; - } - else - { - MMC5ROMWrProtect[0]=MMC5ROMWrProtect[1]=0; - MMC5WRAM(0x8000,PRGBanks[1]&7&0xFE); - MMC5WRAM(0xA000,(PRGBanks[1]&7&0xFE)+1); - } - MMC5MemIn[3]=MMC5MemIn[4]=1; - MMC5ROMWrProtect[2]=MMC5ROMWrProtect[3]=1; - setprg16(0xC000,(PRGBanks[3]&0x7F)>>1); - break; - case 2: if(PRGBanks[1]&0x80) - { - MMC5MemIn[1]=MMC5MemIn[2]=1; - MMC5ROMWrProtect[0]=MMC5ROMWrProtect[1]=1; - setprg16(0x8000,(PRGBanks[1]&0x7F)>>1); - } - else - { - MMC5ROMWrProtect[0]=MMC5ROMWrProtect[1]=0; - MMC5WRAM(0x8000,PRGBanks[1]&7&0xFE); - MMC5WRAM(0xA000,(PRGBanks[1]&7&0xFE)+1); - } - if(PRGBanks[2]&0x80) - { - MMC5ROMWrProtect[2]=1; - MMC5MemIn[3]=1; - setprg8(0xC000,PRGBanks[2]&0x7F); - } - else - { - MMC5ROMWrProtect[2]=0; - MMC5WRAM(0xC000,PRGBanks[2]&7); - } - MMC5MemIn[4]=1; - MMC5ROMWrProtect[3]=1; - setprg8(0xE000,PRGBanks[3]&0x7F); - break; - case 3: for(x=0;x<3;x++) - if(PRGBanks[x]&0x80) - { - MMC5ROMWrProtect[x]=1; - setprg8(0x8000+(x<<13),PRGBanks[x]&0x7F); - MMC5MemIn[1+x]=1; - } - else - { - MMC5ROMWrProtect[x]=0; - MMC5WRAM(0x8000+(x<<13),PRGBanks[x]&7); - } - MMC5MemIn[4]=1; - MMC5ROMWrProtect[3]=1; - setprg8(0xE000,PRGBanks[3]&0x7F); - break; - } -} - -static DECLFW(Mapper5_write) -{ - if(A>=0x5120&&A<=0x5127) - { - ABMode = 0; - CHRBanksA[A&7]=V; - MMC5CHRA(); - } - else switch(A) - { - case 0x5105: { - int x; - for(x=0;x<4;x++) - { - switch((V>>(x<<1))&3) - { - case 0:PPUNTARAM|=1<>3)&0x1F;break; - case 0x5202: MMC5HackSPPage=V&0x3F;break; - case 0x5203: X6502_IRQEnd(FCEU_IQEXT);IRQScanline=V;break; - case 0x5204: X6502_IRQEnd(FCEU_IQEXT);IRQEnable=V&0x80;break; - case 0x5205: mul[0]=V;break; - case 0x5206: mul[1]=V;break; - } -} - -static DECLFR(MMC5_ReadROMRAM) -{ - if(MMC5MemIn[(A-0x6000)>>13]) - return Page[A>>11][A]; - else - return X.DB; -} - -static DECLFW(MMC5_WriteROMRAM) -{ - if(A>=0x8000) - if(MMC5ROMWrProtect[(A-0x8000)>>13]) return; - if(MMC5MemIn[(A-0x6000)>>13]) - if(((WRAMMaskEnable[0]&3)|((WRAMMaskEnable[1]&3)<<2)) == 6) Page[A>>11][A]=V; -} - -static DECLFW(MMC5_ExRAMWr) -{ - if(MMC5HackCHRMode!=3) - ExRAM[A&0x3ff]=V; -} - -static DECLFR(MMC5_ExRAMRd) -{ - /* Not sure if this is correct, so I'll comment it out for now. */ - //if(MMC5HackCHRMode>=2) - return ExRAM[A&0x3ff]; - //else - // return(X.DB); -} - -static DECLFR(MMC5_read) -{ - switch(A) - { - case 0x5204: X6502_IRQEnd(FCEU_IQEXT); - { - uint8 x; - x=MMC5IRQR; - if(!fceuindbg) - MMC5IRQR&=0x40; - return x; - } - case 0x5205: return (mul[0]*mul[1]); - case 0x5206: return ((mul[0]*mul[1])>>8); - } - return(X.DB); -} - -void MMC5Synco(void) -{ - int x; - - MMC5PRG(); - for(x=0;x<4;x++) - { - switch((NTAMirroring>>(x<<1))&3) - { - case 0:PPUNTARAM|=1<>4]+=MMC5Sound.raw<<1; -} - -static void Do5PCMHQ() -{ - int32 V; - if(!(MMC5Sound.rawcontrol&0x40) && MMC5Sound.raw) - for(V=MMC5Sound.BC[2];V>2); - MMC5Sound.env[A>>2]=V; - break; - case 0x2: - case 0x6: if(sfun) sfun(A>>2); - MMC5Sound.wl[A>>2]&=~0x00FF; - MMC5Sound.wl[A>>2]|=V&0xFF; - break; - case 0x3: - case 0x7://printf("%04x:$%02x\n",A,V>>3); - MMC5Sound.wl[A>>2]&=~0x0700; - MMC5Sound.wl[A>>2]|=(V&0x07)<<8; - MMC5Sound.running|=1<<(A>>2); - break; - case 0x15:if(sfun) - { - sfun(0); - sfun(1); - } - MMC5Sound.running&=V; - MMC5Sound.enable=V; - //printf("%02x\n",V); - break; - } -} - -static void Do5SQ(int P) -{ - static int tal[4]={1,2,4,6}; - int32 V,amp,rthresh,wl; - int32 start,end; - - start=MMC5Sound.BC[P]; - end=(SOUNDTS<<16)/soundtsinc; - if(end<=start) return; - MMC5Sound.BC[P]=end; - - wl=MMC5Sound.wl[P]+1; - amp=(MMC5Sound.env[P]&0xF)<<4; - rthresh=tal[(MMC5Sound.env[P]&0xC0)>>6]; - - if(wl>=8 && (MMC5Sound.running&(P+1))) - { - int dc,vc; - - wl<<=18; - dc=MMC5Sound.dcount[P]; - vc=MMC5Sound.vcount[P]; - - for(V=start;V>4]+=amp; - vc-=nesincsize; - while(vc<=0) - { - vc+=wl; - dc=(dc+1)&7; - } - } - MMC5Sound.dcount[P]=dc; - MMC5Sound.vcount[P]=vc; - } -} - -static void Do5SQHQ(int P) -{ - static int tal[4]={1,2,4,6}; - int32 V,amp,rthresh,wl; - - wl=MMC5Sound.wl[P]+1; - amp=((MMC5Sound.env[P]&0xF)<<8); - rthresh=tal[(MMC5Sound.env[P]&0xC0)>>6]; - - if(wl>=8 && (MMC5Sound.running&(P+1))) - { - int dc,vc; - - wl<<=1; - - dc=MMC5Sound.dcount[P]; - vc=MMC5Sound.vcount[P]; - for(V=MMC5Sound.BC[P];V=1) - { - sfun=Do5SQHQ; - psfun=Do5PCMHQ; - } - else - { - sfun=Do5SQ; - psfun=Do5PCM; - } - } - else - { - sfun=0; - psfun=0; - } - memset(MMC5Sound.BC,0,sizeof(MMC5Sound.BC)); - memset(MMC5Sound.vcount,0,sizeof(MMC5Sound.vcount)); - GameExpSound.HiSync=MMC5HiSync; -} - -void NSFMMC5_Init(void) -{ - memset(&MMC5Sound,0,sizeof(MMC5Sound)); - mul[0]=mul[1]=0; - ExRAM=(uint8*)FCEU_gmalloc(1024); - Mapper5_ESI(); - SetWriteHandler(0x5c00,0x5fef,MMC5_ExRAMWr); - SetReadHandler(0x5c00,0x5fef,MMC5_ExRAMRd); - MMC5HackCHRMode=2; - SetWriteHandler(0x5000,0x5015,Mapper5_SW); - SetWriteHandler(0x5205,0x5206,Mapper5_write); - SetReadHandler(0x5205,0x5206,MMC5_read); -} - -void NSFMMC5_Close(void) -{ - FCEU_gfree(ExRAM); - ExRAM=0; -} - -static void GenMMC5Reset(void) -{ - int x; - - for(x=0;x<4;x++) PRGBanks[x]=~0; - for(x=0;x<8;x++) CHRBanksA[x]=~0; - for(x=0;x<4;x++) CHRBanksB[x]=~0; - WRAMMaskEnable[0]=WRAMMaskEnable[1]=~0; - - mmc5psize=mmc5vsize=3; - CHRMode=0; - - NTAMirroring=NTFill=ATFill=0xFF; - - MMC5Synco(); - - SetWriteHandler(0x4020,0x5bff,Mapper5_write); - SetReadHandler(0x4020,0x5bff,MMC5_read); - - SetWriteHandler(0x5c00,0x5fff,MMC5_ExRAMWr); - SetReadHandler(0x5c00,0x5fff,MMC5_ExRAMRd); - - SetWriteHandler(0x6000,0xFFFF,MMC5_WriteROMRAM); - SetReadHandler(0x6000,0xFFFF,MMC5_ReadROMRAM); - - SetWriteHandler(0x5000,0x5015,Mapper5_SW); - SetWriteHandler(0x5205,0x5206,Mapper5_write); - SetReadHandler(0x5205,0x5206,MMC5_read); - - //GameHBIRQHook=MMC5_hb; - FCEU_CheatAddRAM(8,0x6000,WRAM); - FCEU_CheatAddRAM(1,0x5c00,ExRAM); -} - -static SFORMAT MMC5_StateRegs[]={ - { PRGBanks, 4, "PRGB"}, - { CHRBanksA, 8, "CHRA"}, - { CHRBanksB, 4, "CHRB"}, - { &WRAMPage, 1, "WRMP"}, - { WRAMMaskEnable, 2, "WRME"}, - { &ABMode, 1, "ABMD"}, - { &IRQScanline, 1, "IRQS"}, - { &IRQEnable, 1, "IRQE"}, - { &CHRMode, 1, "CHRM"}, - { &NTAMirroring, 1, "NTAM"}, - { &NTFill, 1, "NTFL"}, - { &ATFill, 1, "ATFL"}, - - { &MMC5Sound.wl[0], 2|FCEUSTATE_RLSB, "SDW0"}, - { &MMC5Sound.wl[1], 2|FCEUSTATE_RLSB, "SDW1"}, - { MMC5Sound.env, 2, "SDEV"}, - { &MMC5Sound.enable, 1, "SDEN"}, - { &MMC5Sound.running, 1, "SDRU"}, - { &MMC5Sound.raw, 1, "SDRW"}, - { &MMC5Sound.rawcontrol, 1, "SDRC"}, - {0} -}; - -static void GenMMC5_Init(CartInfo *info, int wsize, int battery) -{ - if(wsize) - { - WRAM=(uint8*)FCEU_gmalloc(wsize*1024); - SetupCartPRGMapping(0x10,WRAM,wsize*1024,1); - AddExState(WRAM, wsize*1024, 0, "WRAM"); - } - - MMC5fill=(uint8*)FCEU_gmalloc(1024); - ExRAM=(uint8*)FCEU_gmalloc(1024); - - AddExState(MMC5_StateRegs, ~0, 0, 0); - AddExState(WRAM, wsize*1024, 0, "WRAM"); - AddExState(ExRAM, 1024, 0, "ERAM"); - AddExState(&MMC5HackSPMode, 1, 0, "SPLM"); - AddExState(&MMC5HackSPScroll, 1, 0, "SPLS"); - AddExState(&MMC5HackSPPage, 1, 0, "SPLP"); - - MMC5WRAMsize=wsize/8; - BuildWRAMSizeTable(); - GameStateRestore=MMC5_StateRestore; - info->Power=GenMMC5Reset; - - if(battery) - { - info->SaveGame[0]=WRAM; - if(wsize<=16) - info->SaveGameLen[0]=8192; - else - info->SaveGameLen[0]=32768; - } - - MMC5HackVROMMask=CHRmask4[0]; - MMC5HackExNTARAMPtr=ExRAM; - MMC5Hack=1; - MMC5HackVROMPTR=CHRptr[0]; - MMC5HackCHRMode=0; - MMC5HackSPMode=MMC5HackSPScroll=MMC5HackSPPage=0; - Mapper5_ESI(); -} - -void Mapper5_Init(CartInfo *info) -{ - GenMMC5_Init(info, DetectMMC5WRAMSize(info->CRC32), info->battery); -} - -// ELROM seems to have 0KB of WRAM -// EKROM seems to have 8KB of WRAM -// ETROM seems to have 16KB of WRAM -// EWROM seems to have 32KB of WRAM - -// ETROM and EWROM are battery-backed, EKROM isn't. - -void ETROM_Init(CartInfo *info) -{ - GenMMC5_Init(info, 16,info->battery); -} - -void ELROM_Init(CartInfo *info) -{ - GenMMC5_Init(info,0,0); -} - -void EWROM_Init(CartInfo *info) -{ - GenMMC5_Init(info,32,info->battery); -} - -void EKROM_Init(CartInfo *info) -{ - GenMMC5_Init(info,8,info->battery); -} diff --git a/boards/n106.c b/boards/n106.c deleted file mode 100644 index 311cacb4..00000000 --- a/boards/n106.c +++ /dev/null @@ -1,469 +0,0 @@ -/* 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 uint16 IRQCount; -static uint8 IRQa; - -static uint8 WRAM[8192]; -static uint8 IRAM[128]; - -static DECLFR(AWRAM) -{ - return(WRAM[A-0x6000]); -} - -static DECLFW(BWRAM) -{ - WRAM[A-0x6000]=V; -} - -void Mapper19_ESI(void); - -static uint8 NTAPage[4]; - -static uint8 dopol; -static uint8 gorfus; -static uint8 gorko; - -static void NamcoSound(int Count); -static void NamcoSoundHack(void); -static void DoNamcoSound(int32 *Wave, int Count); -static void DoNamcoSoundHQ(void); -static void SyncHQ(int32 ts); - -static int is210; /* Lesser mapper. */ - -static uint8 PRG[3]; -static uint8 CHR[8]; - -static SFORMAT N106_StateRegs[]={ - {PRG,3,"PRG"}, - {CHR,8,"CHR"}, - {NTAPage,4,"NTA"}, - {0} -}; - -static void SyncPRG(void) -{ - setprg8(0x8000,PRG[0]); - setprg8(0xa000,PRG[1]); - setprg8(0xc000,PRG[2]); - setprg8(0xe000,0x3F); -} - -static void FP_FASTAPASS(1) NamcoIRQHook(int a) -{ - if(IRQa) - { - IRQCount+=a; - if(IRQCount>=0x7FFF) - { - X6502_IRQBegin(FCEU_IQEXT); - IRQa=0; - IRQCount=0x7FFF; //7FFF; - } - } -} - -static DECLFR(Namco_Read4800) -{ - uint8 ret=IRAM[dopol&0x7f]; - /* Maybe I should call NamcoSoundHack() here? */ - if(!fceuindbg) - if(dopol&0x80) - dopol=(dopol&0x80)|((dopol+1)&0x7f); - return ret; -} - -static DECLFR(Namco_Read5000) -{ - return(IRQCount); -} - -static DECLFR(Namco_Read5800) -{ - return(IRQCount>>8); -} - -static void FASTAPASS(2) DoNTARAMROM(int w, uint8 V) -{ - NTAPage[w]=V; - if(V>=0xE0) - setntamem(NTARAM+((V&1)<<10), 1, w); - else - { - V&=CHRmask1[0]; - setntamem(CHRptr[0]+(V<<10), 0, w); - } -} - -static void FixNTAR(void) -{ - int x; - for(x=0;x<4;x++) - DoNTARAMROM(x,NTAPage[x]); -} - -static void FASTAPASS(2) DoCHRRAMROM(int x, uint8 V) -{ - CHR[x]=V; - if(!is210 && !((gorfus>>((x>>2)+6))&1) && (V>=0xE0)) - { - // printf("BLAHAHA: %d, %02x\n",x,V); - //setchr1r(0x10,x<<10,V&7); - } - else - setchr1(x<<10,V); -} - -static void FixCRR(void) -{ - int x; - for(x=0;x<8;x++) - DoCHRRAMROM(x,CHR[x]); -} - -static DECLFW(Mapper19C0D8_write) -{ - DoNTARAMROM((A-0xC000)>>11,V); -} - -static uint32 FreqCache[8]; -static uint32 EnvCache[8]; -static uint32 LengthCache[8]; - -static void FixCache(int a,int V) -{ - int w=(a>>3)&0x7; - switch(a&0x07) - { - case 0x00:FreqCache[w]&=~0x000000FF;FreqCache[w]|=V;break; - case 0x02:FreqCache[w]&=~0x0000FF00;FreqCache[w]|=V<<8;break; - case 0x04:FreqCache[w]&=~0x00030000;FreqCache[w]|=(V&3)<<16; - LengthCache[w]=(8-((V>>2)&7))<<2; - break; - case 0x07:EnvCache[w]=(double)(V&0xF)*576716;break; - } -} - -static DECLFW(Mapper19_write) -{ - A&=0xF800; - if(A>=0x8000 && A<=0xb800) - DoCHRRAMROM((A-0x8000)>>11,V); - else switch(A) - { - case 0x4800: - if(dopol&0x40) - { - if(FSettings.SndRate) - { - NamcoSoundHack(); - GameExpSound.Fill=NamcoSound; - GameExpSound.HiFill=DoNamcoSoundHQ; - GameExpSound.HiSync=SyncHQ; - } - FixCache(dopol,V); - } - IRAM[dopol&0x7f]=V; - if(dopol&0x80) - dopol=(dopol&0x80)|((dopol+1)&0x7f); - break; - case 0xf800: - dopol=V;break; - case 0x5000: - IRQCount&=0xFF00;IRQCount|=V;X6502_IRQEnd(FCEU_IQEXT);break; - case 0x5800: - IRQCount&=0x00ff;IRQCount|=(V&0x7F)<<8; - IRQa=V&0x80; - X6502_IRQEnd(FCEU_IQEXT); - break; - case 0xE000: - gorko=V&0xC0; - PRG[0]=V&0x3F; - SyncPRG(); - break; - case 0xE800: - gorfus=V&0xC0; - FixCRR(); - PRG[1]=V&0x3F; - SyncPRG(); - break; - case 0xF000: - PRG[2]=V&0x3F; - SyncPRG(); - break; - } -} - -static int dwave=0; - -static void NamcoSoundHack(void) -{ - int32 z,a; - if(FSettings.soundq>=1) - { - DoNamcoSoundHQ(); - return; - } - z=((SOUNDTS<<16)/soundtsinc)>>4; - a=z-dwave; - if(a) DoNamcoSound(&Wave[dwave], a); - dwave+=a; -} - -static void NamcoSound(int Count) -{ - int32 z,a; - z=((SOUNDTS<<16)/soundtsinc)>>4; - a=z-dwave; - if(a) DoNamcoSound(&Wave[dwave], a); - dwave=0; -} - -static uint32 PlayIndex[8]; -static int32 vcount[8]; -static int32 CVBC; - -#define TOINDEX (16+1) - -// 16:15 -static void SyncHQ(int32 ts) -{ - CVBC=ts; -} - - -/* Things to do: - 1 Read freq low - 2 Read freq mid - 3 Read freq high - 4 Read envelope - ...? -*/ - -static INLINE uint32 FetchDuff(uint32 P, uint32 envelope) -{ - uint32 duff; - duff=IRAM[((IRAM[0x46+(P<<3)]+(PlayIndex[P]>>TOINDEX))&0xFF)>>1]; - if((IRAM[0x46+(P<<3)]+(PlayIndex[P]>>TOINDEX))&1) - duff>>=4; - duff&=0xF; - duff=(duff*envelope)>>16; - return(duff); -} - -static void DoNamcoSoundHQ(void) -{ - int32 P,V; - int32 cyclesuck=(((IRAM[0x7F]>>4)&7)+1)*15; - - for(P=7;P>=(7-((IRAM[0x7F]>>4)&7));P--) - { - if((IRAM[0x44+(P<<3)]&0xE0) && (IRAM[0x47+(P<<3)]&0xF)) - { - uint32 freq; - int32 vco; - uint32 duff2,lengo,envelope; - - vco=vcount[P]; - freq=FreqCache[P]; - envelope=EnvCache[P]; - lengo=LengthCache[P]; - - duff2=FetchDuff(P,envelope); - for(V=CVBC<<1;V>1]+=duff2; - if(!vco) - { - PlayIndex[P]+=freq; - while((PlayIndex[P]>>TOINDEX)>=lengo) PlayIndex[P]-=lengo<=7-((IRAM[0x7F]>>4)&7);P--) - { - if((IRAM[0x44+(P<<3)]&0xE0) && (IRAM[0x47+(P<<3)]&0xF)) - { - int32 inc; - uint32 freq; - int32 vco; - uint32 duff,duff2,lengo,envelope; - - vco=vcount[P]; - freq=FreqCache[P]; - envelope=EnvCache[P]; - lengo=LengthCache[P]; - - if(!freq) {/*printf("Ack");*/ continue;} - - { - int c=((IRAM[0x7F]>>4)&7)+1; - inc=(long double)(FSettings.SndRate<<15)/((long double)freq*21477272/((long double)0x400000*c*45)); - } - - duff=IRAM[(((IRAM[0x46+(P<<3)]+PlayIndex[P])&0xFF)>>1)]; - if((IRAM[0x46+(P<<3)]+PlayIndex[P])&1) - duff>>=4; - duff&=0xF; - duff2=(duff*envelope)>>19; - for(V=0;V=inc) - { - PlayIndex[P]++; - if(PlayIndex[P]>=lengo) - PlayIndex[P]=0; - vco-=inc; - duff=IRAM[(((IRAM[0x46+(P<<3)]+PlayIndex[P])&0xFF)>>1)]; - if((IRAM[0x46+(P<<3)]+PlayIndex[P])&1) - duff>>=4; - duff&=0xF; - duff2=(duff*envelope)>>19; - } - Wave[V>>4]+=duff2; - vco+=0x8000; - } - vcount[P]=vco; - } - } -} - -static void Mapper19_StateRestore(int version) -{ - SyncPRG(); - FixNTAR(); - FixCRR(); - int x; - for(x=0x40;x<0x80;x++) - FixCache(x,IRAM[x]); -} - -static void M19SC(void) -{ - if(FSettings.SndRate) - Mapper19_ESI(); -} - -void Mapper19_ESI(void) -{ - GameExpSound.RChange=M19SC; - memset(vcount,0,sizeof(vcount)); - memset(PlayIndex,0,sizeof(PlayIndex)); - CVBC=0; -} - -void NSFN106_Init(void) -{ - SetWriteHandler(0xf800,0xffff,Mapper19_write); - SetWriteHandler(0x4800,0x4fff,Mapper19_write); - SetReadHandler(0x4800,0x4fff,Namco_Read4800); - Mapper19_ESI(); -} - -static int battery=0; - -static void N106_Power(void) -{ - int x; - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x8000,0xffff,Mapper19_write); - SetWriteHandler(0x4020,0x5fff,Mapper19_write); - if(!is210) - { - SetWriteHandler(0xc000,0xdfff,Mapper19C0D8_write); - SetReadHandler(0x4800,0x4fff,Namco_Read4800); - SetReadHandler(0x5000,0x57ff,Namco_Read5000); - SetReadHandler(0x5800,0x5fff,Namco_Read5800); - NTAPage[0]=NTAPage[1]=NTAPage[2]=NTAPage[3]=0xFF; - FixNTAR(); - } - - SetReadHandler(0x6000,0x7FFF,AWRAM); - SetWriteHandler(0x6000,0x7FFF,BWRAM); - FCEU_CheatAddRAM(8,0x6000,WRAM); - - gorfus=0xFF; - SyncPRG(); - FixCRR(); - - if(!battery) - { - FCEU_dwmemset(WRAM,0,8192); - FCEU_dwmemset(IRAM,0,128); - } - for(x=0x40;x<0x80;x++) - FixCache(x,IRAM[x]); -} - -void Mapper19_Init(CartInfo *info) -{ - is210=0; - battery=info->battery; - info->Power=N106_Power; - - MapIRQHook=NamcoIRQHook; - GameStateRestore=Mapper19_StateRestore; - GameExpSound.RChange=M19SC; - - if(FSettings.SndRate) - Mapper19_ESI(); - - AddExState(WRAM, 8192, 0, "WRAM"); - AddExState(IRAM, 128, 0, "WRAM"); - AddExState(N106_StateRegs, ~0, 0, 0); - - if(info->battery) - { - info->SaveGame[0]=WRAM; - info->SaveGameLen[0]=8192; - info->SaveGame[1]=IRAM; - info->SaveGameLen[1]=128; - } -} - -static void Mapper210_StateRestore(int version) -{ - SyncPRG(); - FixCRR(); -} - -void Mapper210_Init(CartInfo *info) -{ - is210=1; - GameStateRestore=Mapper210_StateRestore; - info->Power=N106_Power; - AddExState(WRAM, 8192, 0, "WRAM"); -} diff --git a/boards/sachen.c b/boards/sachen.c deleted file mode 100644 index 64ad5f6d..00000000 --- a/boards/sachen.c +++ /dev/null @@ -1,398 +0,0 @@ -/* 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 cmd; -static uint8 latch[8]; - -static void S74LS374MSync(uint8 mirr) -{ - switch(mirr&3) - { - case 0:setmirror(MI_V);break; - case 1:setmirror(MI_H);break; - case 2:setmirrorw(0,1,1,1);break; - case 3:setmirror(MI_0);break; - } -} - -static void S74LS374NSynco(void) -{ - setprg32(0x8000,latch[0]); - setchr8(latch[1]|latch[3]|latch[4]); - S74LS374MSync(latch[2]); -} - -static DECLFW(S74LS374NWrite) -{ - A&=0x4101; - if(A==0x4100) - cmd=V&7; - else - { - switch(cmd) - { - case 2:latch[0]=V&1; latch[3]=(V&1)<<3;break; - case 4:latch[4]=(V&1)<<2;break; - case 5:latch[0]=V&7;break; - case 6:latch[1]=V&3;break; - case 7:latch[2]=V>>1;break; - } - S74LS374NSynco(); - } -} - -static DECLFR(S74LS374NRead) -{ - uint8 ret; - if((A&0x4100)==0x4100) - ret=(X.DB&0xC0)|((~cmd)&0x3F); - else - ret=X.DB; - return ret; -} - -static void S74LS374NPower(void) -{ - latch[0]=latch[1]=latch[2]=latch[3]=latch[4]=0; - S74LS374NSynco(); - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x4100,0x7FFF,S74LS374NWrite); - SetReadHandler(0x4100,0x5fff,S74LS374NRead); -} - -static void S74LS374NRestore(int version) -{ - S74LS374NSynco(); -} - -void S74LS374N_Init(CartInfo *info) -{ - info->Power=S74LS374NPower; - GameStateRestore=S74LS374NRestore; - AddExState(latch, 5, 0, "LATC"); - AddExState(&cmd, 1, 0, "CMD"); -} - -static void S74LS374NASynco(void) -{ - setprg32(0x8000,latch[0]); - setchr8(latch[1]); - S74LS374MSync(latch[2]); -} - -static DECLFW(S74LS374NAWrite) -{ - A&=0x4101; - if(A==0x4100) - cmd=V&7; - else - { - switch(cmd) - { - case 0:latch[0]=0;latch[1]=3;break; - case 2:latch[3]=(V&1)<<3;break; - case 4:latch[1]=(latch[1]&6)|(V&3);break; - case 5:latch[0]=V&1;break; - case 6:latch[1]=(latch[1]&1)|latch[3]|((V&3)<<1);break; - case 7:latch[2]=V&1;break; - } - S74LS374NASynco(); - } -} - -static void S74LS374NAPower(void) -{ - latch[0]=latch[2]=latch[3]=latch[4]=0; - latch[1]=3; - S74LS374NASynco(); - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x4100,0x7FFF,S74LS374NAWrite); -} - -void S74LS374NA_Init(CartInfo *info) -{ - info->Power=S74LS374NAPower; - GameStateRestore=S74LS374NRestore; - AddExState(latch, 5, 0, "LATC"); - AddExState(&cmd, 1, 0, "CMD"); -} - -static int type; -static void S8259Synco(void) -{ - int x; - setprg32(0x8000,latch[5]&7); - - if(!UNIFchrrama) // No CHR RAM? Then BS'ing is ok. - { - for(x=0;x<4;x++) - { - int bank; - if(latch[7]&1) - bank=(latch[0]&0x7)|((latch[4]&7)<<3); - else - bank=(latch[x]&0x7)|((latch[4]&7)<<3); - switch (type) - { - case 00: bank=(bank<<1)|(x&1); setchr2(0x800*x,bank); break; - case 01: setchr2(0x800*x,bank); break; - case 02: bank=(bank<<2)|(x&3); setchr2(0x800*x,bank); break; - case 03: bank=latch[x]&7; - switch (x&3) - { - case 01: bank|=(latch[4]&1)<<4;break; - case 02: bank|=(latch[4]&2)<<3;break; - case 03: bank|=((latch[4]&4)<<2)|((latch[6]&1)<<3);break; - } - setchr1(0x400*x,bank); - setchr4(0x1000,~0); - break; - } - } - } - if(!(latch[7]&1)) - S74LS374MSync(latch[7]>>1); - else - setmirror(MI_V); -} - -static DECLFW(S8259Write) -{ - A&=0x4101; - if(A==0x4100) - cmd=V; - else - { - latch[cmd&7]=V; - S8259Synco(); - } -} - -static void S8259Reset(void) -{ - int x; - cmd=0; - - for(x=0;x<8;x++) latch[x]=0; - setchr8(0); - - S8259Synco(); - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x4100,0x7FFF,S8259Write); -} - -static void S8259Restore(int version) -{ - S8259Synco(); -} - -void S8259A_Init(CartInfo *info) // Kevin's Horton 141 mapper -{ - info->Power=S8259Reset; - GameStateRestore=S8259Restore; - AddExState(latch, 8, 0, "LATC"); - AddExState(&cmd, 1, 0, "CMD"); - type=0; -} - -void S8259B_Init(CartInfo *info) // Kevin's Horton 138 mapper -{ - info->Power=S8259Reset; - GameStateRestore=S8259Restore; - AddExState(latch, 8, 0, "LATC"); - AddExState(&cmd, 1, 0, "CMD"); - type=1; -} - -void S8259C_Init(CartInfo *info) // Kevin's Horton 139 mapper -{ - info->Power=S8259Reset; - GameStateRestore=S8259Restore; - AddExState(latch, 8, 0, "LATC"); - AddExState(&cmd, 1, 0, "CMD"); - type=2; -} - -void S8259D_Init(CartInfo *info) // Kevin's Horton 137 mapper -{ - info->Power=S8259Reset; - GameStateRestore=S8259Restore; - AddExState(latch, 8, 0, "LATC"); - AddExState(&cmd, 1, 0, "CMD"); - type=3; -} - -static void(*WSync)(void); - -static DECLFW(SAWrite) -{ - if(A&0x100) - { - latch[0]=V; - WSync(); - } -} - -static void SAPower(void) -{ - latch[0]=0; - WSync(); - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x4100,0x5FFF,SAWrite); -} - -static void SARestore(int version) -{ - WSync(); -} - -static DECLFW(SADWrite) -{ - latch[0]=V; - WSync(); -} - -static void SADPower(void) -{ - latch[0]=0; - WSync(); - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x8000,0xFFFF,SADWrite); -} - -static void SA0161MSynco() -{ - setprg32(0x8000,(latch[0]>>3)&1); - setchr8(latch[0]&7); -} - -static void SA72007Synco() -{ - setprg32(0x8000,0); - setchr8(latch[0]>>7); -} - -static void SA72008Synco() -{ - setprg32(0x8000,(latch[0]>>2)&1); - setchr8(latch[0]&3); -} - -void SA0161M_Init(CartInfo *info) -{ - WSync=SA0161MSynco; - GameStateRestore=SARestore; - info->Power=SAPower; - AddExState(&latch[0], 1, 0, "LATC"); -} - -void SA72007_Init(CartInfo *info) -{ - WSync=SA72007Synco; - GameStateRestore=SARestore; - info->Power=SAPower; - AddExState(&latch[0], 1, 0, "LATC"); -} - -void SA72008_Init(CartInfo *info) -{ - WSync=SA72008Synco; - GameStateRestore=SARestore; - info->Power=SAPower; - AddExState(&latch[0], 1, 0, "LATC"); -} - -void SA0036_Init(CartInfo *info) -{ - WSync=SA72007Synco; - GameStateRestore=SARestore; - info->Power=SADPower; - AddExState(&latch[0], 1, 0, "LATC"); -} - -void SA0037_Init(CartInfo *info) -{ - WSync=SA0161MSynco; - GameStateRestore=SARestore; - info->Power=SADPower; - AddExState(&latch[0], 1, 0, "LATC"); -} - -static void TCU01Synco() -{ - setprg32(0x8000,(latch[0]>>2)&1); - setchr8((latch[0]>>3)&0xF); -} - -static DECLFW(TCWrite) -{ - if((A&0x103)==0x102) - { - latch[0]=V; - TCU01Synco(); - } -} - -static void TCU01Reset(void) -{ - latch[0]=0; - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x4100,0xFFFF,TCWrite); - TCU01Synco(); -} - -static void TCU01Restore(int version) -{ - TCU01Synco(); -} - -void TCU01_Init(CartInfo *info) -{ - GameStateRestore=TCU01Restore; - info->Power=TCU01Reset; - AddExState(&latch[0], 1, 0, "LATC"); -} - -static DECLFR(TCA01Read) -{ - uint8 ret; - if((A&0x4100)==0x4100) - ret=(X.DB&0xC0)|((~A)&0x3F); - else - ret=X.DB; - return ret; -} - -static void TCA01Reset(void) -{ - setprg16(0x8000,0); - setprg16(0xC000,1); - setchr8(0); - SetReadHandler(0x8000,0xFFFF,CartBR); - SetReadHandler(0x4100,0x5FFF,TCA01Read); -} - -void TCA01_Init(CartInfo *info) -{ - info->Power=TCA01Reset; -} - diff --git a/boards/sheroes.c b/boards/sheroes.c deleted file mode 100644 index ac081007..00000000 --- a/boards/sheroes.c +++ /dev/null @@ -1,86 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2006 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" -#include "mmc3.h" - -static uint8 *CHRRAM; -static uint8 tekker; - -static void MSHCW(uint32 A, uint8 V) -{ - if(EXPREGS[0]&0x40) - setchr8r(0x10,0); - else - { - if(A<0x800) - setchr1(A,V|((EXPREGS[0]&8)<<5)); - else if(A<0x1000) - setchr1(A,V|((EXPREGS[0]&4)<<6)); - else if(A<0x1800) - setchr1(A,V|((EXPREGS[0]&1)<<8)); - else - setchr1(A,V|((EXPREGS[0]&2)<<7)); - } -} - -static DECLFW(MSHWrite) -{ - EXPREGS[0]=V; - FixMMC3CHR(MMC3_cmd); -} - -static DECLFR(MSHRead) -{ - return(tekker); -} - -static void MSHReset(void) -{ - MMC3RegReset(); - tekker^=0xFF; -} - -static void MSHPower(void) -{ - tekker=0x00; - GenMMC3Power(); - SetWriteHandler(0x4100,0x4100,MSHWrite); - SetReadHandler(0x4100,0x4100,MSHRead); -} - -static void MSHClose(void) -{ - if(CHRRAM) - FCEU_gfree(CHRRAM); - CHRRAM=NULL; -} - -void UNLSHeroes_Init(CartInfo *info) -{ - GenMMC3_Init(info, 256, 512, 0, 0); - cwrap=MSHCW; - info->Power=MSHPower; - info->Reset=MSHReset; - info->Close=MSHClose; - CHRRAM = (uint8*)FCEU_gmalloc(8192); - SetupCartCHRMapping(0x10, CHRRAM, 8192, 1); - AddExState(EXPREGS, 4, 0, "EXPR"); -} diff --git a/boards/sl1632.c b/boards/sl1632.c deleted file mode 100644 index 3d0e386a..00000000 --- a/boards/sl1632.c +++ /dev/null @@ -1,159 +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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static uint8 chrcmd[8], prg0, prg1, brk, mirr; -static uint8 reg[8], cmd; -static uint8 IRQCount,IRQLatch,IRQa; -static uint8 IRQReload; -static SFORMAT StateRegs[]= -{ - {reg, 8, "MMCREG"}, - {&cmd, 1, "MMCCMD"}, - {chrcmd, 8, "CHRCMD"}, - {&prg0, 1, "PRG0"}, - {&prg1, 1, "PRG1"}, - {&brk, 1, "BRK"}, - {&mirr, 1, "MIRR"}, - {&IRQReload, 1, "IRQR"}, - {&IRQCount, 1, "IRQC"}, - {&IRQLatch, 1, "IRQL"}, - {&IRQa, 1, "IRQA"}, - {0} -}; - -static void Sync(void) -{ -// if(brk&2) -// { -// setprg16(0x8000,~0); -// setprg16(0xC000,~0); -// } -// else - { - setprg8(0x8000,prg0); - setprg8(0xA000,prg1); - } - int i; - for(i=0; i<8; i++) - setchr1(i<<10,chrcmd[i]); - setmirror(mirr^1); -} - -static void Sync2(void) -{ - setprg8(0x8000,reg[6]&0x3F); - setprg8(0xA000,reg[7]&0x3F); - setchr2(0x0000,reg[0]>>1); - setchr2(0x8000,reg[1]>>1); - setchr1(0x1000,reg[2]); - setchr1(0x1400,reg[3]); - setchr1(0x1800,reg[4]); - setchr1(0x1C00,reg[5]); - setmirror(mirr^1); -} - -static DECLFW(UNLSL1632CMDWrite) -{ - FCEU_printf("bs %04x %02x\n",A,V); -// if((A&0xA131)==0xA131) brk=V; - if((A&0xA131)==0xA131) brk=V; - if(brk==2) - { - switch(A&0xE001) - { - case 0x8000: cmd=V&7; break; - case 0x8001: reg[cmd]=V; Sync(); break; - case 0xA000: mirr=V&1; break; - case 0xC000: IRQLatch=V; break; - case 0xC001: IRQReload=1; break; - case 0xE000: X6502_IRQEnd(FCEU_IQEXT); IRQa=0; break; - case 0xE001: IRQa=1; break; - } - Sync2(); - } - else - { - switch(A&0xF003) - { - case 0x8000: prg0=V; break; - case 0xA000: prg1=V; break; - case 0x9000: mirr=V&1; break; - case 0xB000: chrcmd[0]=(chrcmd[0]&0xF0)|(V&0x0F); break; - case 0xB001: chrcmd[0]=(chrcmd[0]&0x0F)|(V<<4); break; - case 0xB002: chrcmd[1]=(chrcmd[1]&0xF0)|(V&0x0F); break; - case 0xB003: chrcmd[1]=(chrcmd[1]&0x0F)|(V<<4); break; - case 0xC000: chrcmd[2]=(chrcmd[2]&0xF0)|(V&0x0F); break; - case 0xC001: chrcmd[2]=(chrcmd[2]&0x0F)|(V<<4); break; - case 0xC002: chrcmd[3]=(chrcmd[3]&0xF0)|(V&0x0F); break; - case 0xC003: chrcmd[3]=(chrcmd[3]&0x0F)|(V<<4); break; - case 0xD000: chrcmd[4]=(chrcmd[4]&0xF0)|(V&0x0F); break; - case 0xD001: chrcmd[4]=(chrcmd[4]&0x0F)|(V<<4); break; - case 0xD002: chrcmd[5]=(chrcmd[5]&0xF0)|(V&0x0F); break; - case 0xD003: chrcmd[5]=(chrcmd[5]&0x0F)|(V<<4); break; - case 0xE000: chrcmd[6]=(chrcmd[6]&0xF0)|(V&0x0F); break; - case 0xE001: chrcmd[6]=(chrcmd[6]&0x0F)|(V<<4); break; - case 0xE002: chrcmd[7]=(chrcmd[7]&0xF0)|(V&0x0F); break; - case 0xE003: chrcmd[7]=(chrcmd[7]&0x0F)|(V<<4); break; - } - Sync(); - } -} - -static void UNLSL1632IRQHook(void) -{ - int count = IRQCount; - if((scanline==128)&&IRQa)X6502_IRQBegin(FCEU_IQEXT); - if(!count || IRQReload) - { - IRQCount = IRQLatch; - IRQReload = 0; - } - else - IRQCount--; - if(!IRQCount) - { - if(IRQa) - { - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -static void StateRestore(int version) -{ - Sync(); -} - -static void UNLSL1632Power(void) -{ - setprg16(0xC000,~0); - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x8000,0xFFFF,UNLSL1632CMDWrite); -} - -void UNLSL1632_Init(CartInfo *info) -{ - info->Power=UNLSL1632Power; - GameHBIRQHook2=UNLSL1632IRQHook; - GameStateRestore=StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/boards/sonic5.c b/boards/sonic5.c deleted file mode 100644 index 1da341fe..00000000 --- a/boards/sonic5.c +++ /dev/null @@ -1,71 +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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" -#include "mmc3.h" - -static uint8 m_perm[8] = {0, 1, 0, 3, 0, 5, 6, 7}; - -static void UNLSonicPW(uint32 A, uint8 V) -{ - if(EXPREGS[0]&0x80) - { - uint8 bank=EXPREGS[0]&0x1F; - if(EXPREGS[0]&0x20) - setprg32(0x8000,bank>>2); - else - { - setprg16(0x8000,bank); - setprg16(0xC000,bank); - } - } - else - setprg8(A,V&0x3F); -} - -static DECLFW(UNLSonicWrite8000) -{ - if(V&0x80) - MMC3_CMDWrite(A,V); - else - MMC3_CMDWrite(A,m_perm[V&7]); -} - -static DECLFW(UNLSonicWriteLo) -{ - EXPREGS[0]=V; - FixMMC3PRG(MMC3_cmd); -} - -static void UNLSonicPower(void) -{ - EXPREGS[0]=EXPREGS[1]=EXPREGS[2]=0; - GenMMC3Power(); - SetWriteHandler(0x5000,0x5FFF,UNLSonicWriteLo); -// SetWriteHandler(0x8000,0x8000,UNLSonicWrite8000); -} - -void UNLSonic_Init(CartInfo *info) -{ - GenMMC3_Init(info, 256, 256, 0, 0); - pwrap=UNLSonicPW; - info->Power=UNLSonicPower; - AddExState(EXPREGS, 3, 0, "EXPR"); -} diff --git a/boards/subor.c b/boards/subor.c deleted file mode 100644 index 9f0386db..00000000 --- a/boards/subor.c +++ /dev/null @@ -1,79 +0,0 @@ -#include "mapinc.h" - -static uint8 mode; -static uint8 DRegs[4]; - -static SFORMAT StateRegs[]= -{ - {DRegs, 4, "DREG"}, - {0} -}; - -static void Sync(void) -{ - int base, bank; - base = ((DRegs[0]^DRegs[1])&0x10)<<1; - bank = (DRegs[2]^DRegs[3])&0x1f; - - if(DRegs[1]&0x08) - { - bank &= 0xfe; - if(mode==0) - { - setprg16(0x8000,base+bank+1); - setprg16(0xC000,base+bank+0); - } - else - { - setprg16(0x8000,base+bank+0); - setprg16(0xC000,base+bank+1); - } - } - else - { - if(DRegs[1]&0x04) - { - setprg16(0x8000,0x1f); - setprg16(0xC000,base+bank); - } - else - { - setprg16(0x8000,base+bank); - if(mode==0) - setprg16(0xC000,0x20); - else - setprg16(0xC000,0x07); - } - } -} - -static DECLFW(Mapper167_write) -{ - DRegs[(A>>13)&0x03]=V; - Sync(); -} - -static void StateRestore(int version) -{ - Sync(); -} - -void Mapper166_init(void) -{ - mode=1; - DRegs[0]=DRegs[1]=DRegs[2]=DRegs[3]=0; - Sync(); - SetWriteHandler(0x8000,0xFFFF,Mapper167_write); - GameStateRestore=StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -void Mapper167_init(void) -{ - mode=0; - DRegs[0]=DRegs[1]=DRegs[2]=DRegs[3]=0; - Sync(); - SetWriteHandler(0x8000,0xFFFF,Mapper167_write); - GameStateRestore=StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/boards/super24.c b/boards/super24.c deleted file mode 100644 index 745e723e..00000000 --- a/boards/super24.c +++ /dev/null @@ -1,99 +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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" -#include "mmc3.h" - -static uint8 *CHRRAM = NULL; -static int masko8[8]={63,31,15,1,3,0,0,0}; - -static void Super24PW(uint32 A, uint8 V) -{ - uint32 NV=V&masko8[EXPREGS[0]&7]; - NV|=(EXPREGS[1]<<1); - setprg8r((NV>>6)&0xF,A,NV); -} - -static void Super24CW(uint32 A, uint8 V) -{ - if(EXPREGS[0]&0x20) - setchr1r(0x10,A,V); - else - { - uint32 NV=V|(EXPREGS[2]<<3); - setchr1r((NV>>9)&0xF,A,NV); - } -} - -static DECLFW(Super24Write) -{ - switch(A) - { - case 0x5FF0: EXPREGS[0]=V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); - break; - case 0x5FF1: EXPREGS[1]=V; - FixMMC3PRG(MMC3_cmd); - break; - case 0x5FF2: EXPREGS[2]=V; - FixMMC3CHR(MMC3_cmd); - break; - } -} - -static void Super24Power(void) -{ - EXPREGS[0]=0x24; - EXPREGS[1]=159; - EXPREGS[2]=0; - GenMMC3Power(); - SetWriteHandler(0x5000,0x7FFF,Super24Write); - SetReadHandler(0x8000,0xFFFF,CartBR); -} - -static void Super24Reset(void) -{ - EXPREGS[0]=0x24; - EXPREGS[1]=159; - EXPREGS[2]=0; - MMC3RegReset(); -} - -static void Super24Close(void) -{ - if(CHRRAM) - FCEU_gfree(CHRRAM); - CHRRAM = NULL; -} - -void Super24_Init(CartInfo *info) -{ - GenMMC3_Init(info, 128, 256, 0, 0); - info->Power=Super24Power; - info->Reset=Super24Reset; - info->Close=Super24Close; - cwrap=Super24CW; - pwrap=Super24PW; - CHRRAM=(uint8*)FCEU_gmalloc(8192); - SetupCartCHRMapping(0x10, CHRRAM, 8192, 1); - AddExState(CHRRAM, 8192, 0, "CHRR"); - AddExState(EXPREGS, 3, 0, "BIG2"); -} diff --git a/boards/supervision.c b/boards/supervision.c deleted file mode 100644 index 61a373d3..00000000 --- a/boards/supervision.c +++ /dev/null @@ -1,74 +0,0 @@ -/* 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 cmd0, cmd1; - -static void DoSuper(void) -{ - setprg8r((cmd0&0xC)>>2,0x6000,((cmd0&0x3)<<4)|0xF); - if(cmd0&0x10) - { - setprg16r((cmd0&0xC)>>2,0x8000,((cmd0&0x3)<<3)|(cmd1&7)); - setprg16r((cmd0&0xC)>>2,0xc000,((cmd0&0x3)<<3)|7); - } - else - setprg32r(4,0x8000,0); - setmirror(((cmd0&0x20)>>5)^1); -} - -static DECLFW(SuperWrite) -{ - if(!(cmd0&0x10)) - { - cmd0=V; - DoSuper(); - } -} - -static DECLFW(SuperHi) -{ - cmd1=V; - DoSuper(); -} - -static void SuperReset(void) -{ - SetWriteHandler(0x6000,0x7FFF,SuperWrite); - SetWriteHandler(0x8000,0xFFFF,SuperHi); - SetReadHandler(0x6000,0xFFFF,CartBR); - cmd0=cmd1=0; - setprg32r(4,0x8000,0); - setchr8(0); -} - -static void SuperRestore(int version) -{ - DoSuper(); -} - -void Supervision16_Init(CartInfo *info) -{ - AddExState(&cmd0, 1, 0,"L1"); - AddExState(&cmd1, 1, 0,"L2"); - info->Power=SuperReset; - GameStateRestore=SuperRestore; -} diff --git a/boards/t-262.c b/boards/t-262.c deleted file mode 100644 index 98cc24e5..00000000 --- a/boards/t-262.c +++ /dev/null @@ -1,83 +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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static uint16 addrreg; -static uint8 datareg; -static uint8 busy; -static SFORMAT StateRegs[]= -{ - {&addrreg, 2, "ADDRREG"}, - {&datareg, 1, "DATAREG"}, - {&busy, 1, "BUSY"}, - {0} -}; - -static void Sync(void) -{ - setprg16(0x8000,(datareg&7)|((addrreg&0x60)>>2)|((addrreg&0x100)>>3)); - setprg16(0xC000,7|((addrreg&0x60)>>2)|((addrreg&0x100)>>3)); - setmirror(((addrreg&2)>>1)^1); -} - -static DECLFW(BMCT262Write) -{ - if(busy||(A==0x8000)) - datareg=V; - else - { - addrreg=A; - busy=1; - } - Sync(); -} - -static void BMCT262Power(void) -{ - setchr8(0); - SetWriteHandler(0x8000,0xFFFF,BMCT262Write); - SetReadHandler(0x8000,0xFFFF,CartBR); - busy=0; - addrreg=0; - datareg=0; - Sync(); -} - -static void BMCT262Reset(void) -{ - busy=0; - addrreg=0; - datareg=0; - Sync(); -} - -static void BMCT262Restore(int version) -{ - Sync(); -} - -void BMCT262_Init(CartInfo *info) -{ - info->Power=BMCT262Power; - info->Reset=BMCT262Reset; - GameStateRestore=BMCT262Restore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/boards/tengen.c b/boards/tengen.c deleted file mode 100644 index a4f33f52..00000000 --- a/boards/tengen.c +++ /dev/null @@ -1,198 +0,0 @@ -/* 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 cmd,mir,rmode,IRQmode; -static uint8 DRegs[11]; -static uint8 IRQCount,IRQa,IRQLatch; - -static SFORMAT Rambo_StateRegs[]={ - {&cmd, 1, "CMD"}, - {&mir, 1, "MIR"}, - {&rmode, 1, "RMOD"}, - {&IRQmode, 1, "IRQM"}, - {&IRQCount, 1, "IRQC"}, - {&IRQa, 1, "IRQA"}, - {&IRQLatch, 1, "IRQL"}, - {DRegs, 11, "DREG"}, - {0} -}; - -static void FP_FASTAPASS(2) (*setchr1wrap)(unsigned int A, unsigned int V); -static int nomirror; - -static void FP_FASTAPASS(1) RAMBO1_IRQHook(int a) -{ - static int smallcount; - if(!IRQmode) return; - - smallcount+=a; - while(smallcount>=4) - { - smallcount-=4; - IRQCount--; - if(IRQCount==0xFF) - if(IRQa) X6502_IRQBegin(FCEU_IQEXT); - } -} - -static void RAMBO1_hb(void) -{ - if(IRQmode) return; - if(scanline==240) return; /* hmm. Maybe that should be an mmc3-only call in fce.c. */ - rmode=0; - IRQCount--; - if(IRQCount==0xFF) - { - if(IRQa) - { - rmode = 1; - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -static void Synco(void) -{ - int x; - - if(cmd&0x20) - { - setchr1wrap(0x0000,DRegs[0]); - setchr1wrap(0x0800,DRegs[1]); - setchr1wrap(0x0400,DRegs[8]); - setchr1wrap(0x0c00,DRegs[9]); - } - else - { - setchr1wrap(0x0000,(DRegs[0]&0xFE)); - setchr1wrap(0x0400,(DRegs[0]&0xFE)|1); - setchr1wrap(0x0800,(DRegs[1]&0xFE)); - setchr1wrap(0x0C00,(DRegs[1]&0xFE)|1); - } - - for(x=0;x<4;x++) - setchr1wrap(0x1000+x*0x400,DRegs[2+x]); - - setprg8(0x8000,DRegs[6]); - setprg8(0xA000,DRegs[7]); - - setprg8(0xC000,DRegs[10]); -} - - -static DECLFW(RAMBO1_write) -{ - switch(A&0xF001) - { - case 0xa000: mir=V&1; - if(!nomirror) - setmirror(mir^1); - break; - case 0x8000: cmd = V; - break; - case 0x8001: if((cmd&0xF)<10) - DRegs[cmd&0xF]=V; - else if((cmd&0xF)==0xF) - DRegs[10]=V; - Synco(); - break; - case 0xc000: IRQLatch=V; - if(rmode==1) - IRQCount=IRQLatch; - break; - case 0xc001: rmode=1; - IRQCount=IRQLatch; - IRQmode=V&1; - break; - case 0xE000: IRQa=0; - X6502_IRQEnd(FCEU_IQEXT); - if(rmode==1) - IRQCount=IRQLatch; - break; - case 0xE001: IRQa=1; - if(rmode==1) - IRQCount=IRQLatch; - break; - } -} - -static void RAMBO1_Restore(int version) -{ - Synco(); - if(!nomirror) - setmirror(mir^1); -} - -static void RAMBO1_init(void) -{ - int x; - for(x=0;x<11;x++) - DRegs[x]=~0; - cmd=mir=0; - if(!nomirror) - setmirror(1); - Synco(); - GameHBIRQHook=RAMBO1_hb; - MapIRQHook=RAMBO1_IRQHook; - GameStateRestore=RAMBO1_Restore; - SetWriteHandler(0x8000,0xffff,RAMBO1_write); - AddExState(Rambo_StateRegs, ~0, 0, 0); -} - -static void FP_FASTAPASS(2) CHRWrap(unsigned int A, unsigned int V) -{ - setchr1(A,V); -} - -void Mapper64_init(void) -{ - setchr1wrap=CHRWrap; - nomirror=0; - RAMBO1_init(); -} - -static int MirCache[8]; -static unsigned int PPUCHRBus; - -static void FP_FASTAPASS(2) MirWrap(unsigned int A, unsigned int V) -{ - MirCache[A>>10]=(V>>7)&1; - if(PPUCHRBus==(A>>10)) - setmirror(MI_0+((V>>7)&1)); - setchr1(A,V); -} - -static void FP_FASTAPASS(1) MirrorFear(uint32 A) -{ - A&=0x1FFF; - A>>=10; - PPUCHRBus=A; - setmirror(MI_0+MirCache[A]); -} - -void Mapper158_init(void) -{ - setchr1wrap=MirWrap; - PPU_hook=MirrorFear; - nomirror=1; - RAMBO1_init(); -} diff --git a/cheat.c b/cheat.c index c69c1779..dbe11610 100644 --- a/cheat.c +++ b/cheat.c @@ -236,7 +236,7 @@ void FCEU_LoadGameCheats(FILE *override) char *neo=&tbuf[4+2+2+1+1+1]; if(sscanf(tbuf,"%04x%*[:]%02x%*[:]%02x",&addr,&val,&compare)!=3) continue; - namebuf=malloc(strlen(neo)+1); + namebuf=(char *)malloc(strlen(neo)+1); strcpy(namebuf,neo); } else @@ -244,11 +244,11 @@ void FCEU_LoadGameCheats(FILE *override) char *neo=&tbuf[4+2+1+1]; if(sscanf(tbuf,"%04x%*[:]%02x",&addr,&val)!=2) continue; - namebuf=malloc(strlen(neo)+1); + namebuf=(char *)malloc(strlen(neo)+1); strcpy(namebuf,neo); } - for(x=0;x #include -#include +//#include //mbg merge 7/17/06 removed #include #include // For directories configuration dialog. #undef uint8 @@ -187,11 +187,12 @@ static int soundquality=0; extern int autoHoldKey, autoHoldClearKey; extern int frame_display, input_display; -static unsigned int srendline,erendline; -static unsigned int srendlinen=8; -static unsigned int erendlinen=231; -static unsigned int srendlinep=0; -static unsigned int erendlinep=239; +//mbg merge 7/17/06 why did these have to be unsigned +static int srendline,erendline; +static int srendlinen=8; +static int erendlinen=231; +static int srendlinep=0; +static int erendlinep=239; static unsigned int totallines; diff --git a/fceu.c b/fceu.c index 0fd37743..a6c266c6 100644 --- a/fceu.c +++ b/fceu.c @@ -250,9 +250,10 @@ char lastLoadedGameName [2048] = {0,}; // hack for movie WRAM clearing on record FCEUGI *FCEUI_LoadGame(const char *name, int OverwriteVidMode) { -#ifdef WIN32 - StopSound(); -#endif + //mbg merge 7/17/07 - why is this here +//#ifdef WIN32 +// StopSound(); +//#endif FCEUFILE *fp; char *ipsfn; @@ -262,7 +263,7 @@ FCEUGI *FCEUI_LoadGame(const char *name, int OverwriteVidMode) RewindStatus[0] = RewindStatus[1] = 0; RewindStatus[2] = RewindStatus[3] = 0; - FCEUGameInfo = malloc(sizeof(FCEUGI)); + FCEUGameInfo = (FCEUGI*)malloc(sizeof(FCEUGI)); memset(FCEUGameInfo, 0, sizeof(FCEUGI)); FCEUGameInfo->soundchan = 0; diff --git a/fceu.h b/fceu.h index 624a803a..fa6b9925 100644 --- a/fceu.h +++ b/fceu.h @@ -102,7 +102,7 @@ extern uint8 Exit; extern uint8 pale; extern uint8 vsdip; -#define FCEUDEF_DEBUGGER +//#define FCEUDEF_DEBUGGER //mbg merge 7/17/06 - cleaning out conditional compiles #define JOY_A 1 #define JOY_B 2 diff --git a/fds.c b/fds.c index 901a618e..3d28bd30 100644 --- a/fds.c +++ b/fds.c @@ -74,7 +74,7 @@ static uint8 *diskdatao[8]={0,0,0,0,0,0,0,0}; static uint8 *diskdata[8]={0,0,0,0,0,0,0,0}; -static unsigned int TotalSides; +static int TotalSides; //mbg merge 7/17/06 - unsignedectomy static uint8 DiskWritten=0; /* Set to 1 if disk was written to. */ static uint8 writeskip; static uint32 DiskPtr; @@ -532,7 +532,7 @@ static void RenderSound(void) static void RenderSoundHQ(void) { - int32 x; + uint32 x; //mbg merge 7/17/06 - made this unsigned if(!(SPSG[0x9]&0x80)) for(x=FBC;x #include #include -#include +//#include //mbg merge 7/17/06 - removed #include #include "unzip.h" @@ -289,7 +289,7 @@ FCEUFILE * FCEU_fopen(const char *path, const char *ipsfn, char *mode, char *ext fd = dup(fileno( (FILE *)t)); - fclose(t); + fclose((FILE*)t); //mbg merge 7/17/06 - cast to FILE* lseek(fd, 0, SEEK_SET); @@ -420,7 +420,7 @@ int FCEU_fseek(FCEUFILE *fp, long offset, int whence) switch(whence) { - case SEEK_SET:if(offset>=wz->size) + case SEEK_SET:if(offset>=(long)wz->size) //mbg merge 7/17/06 - added cast to long return(-1); wz->location=offset;break; case SEEK_CUR:if(offset+wz->location>wz->size) @@ -460,12 +460,12 @@ void FCEU_rewind(FCEUFILE *fp) } else /* Rewind */ - fseek(fp->fp,0,SEEK_SET); + fseek((FILE*)fp->fp,0,SEEK_SET); //mbg merge 7/17/06 - added cast to FILE* } int FCEU_read16le(uint16 *val, FCEUFILE *fp) { - uint8 t[2]; + uint8 t[4]; //mbg merge 7/17/06 - changed size from 2 to 4 to avoid dangerous problem with uint32* poking if(fp->type>=1) { diff --git a/general.c b/general.c index 540b2050..7cb93bfb 100644 --- a/general.c +++ b/general.c @@ -25,7 +25,7 @@ #include #include -#include +//#include //mbg merge 7/17/06 - removed #include "types.h" #include "fceu.h" @@ -74,7 +74,7 @@ static int asprintf(char **strp, const char *fmt, ...) int ret; va_start(ap,fmt); - if(!(*strp=malloc(2048))) + if(!(*strp=(char*)malloc(2048))) //mbg merge 7/17/06 cast to char* return(0); ret=vsnprintf(*strp,2048,fmt,ap); va_end(ap); diff --git a/input.c b/input.c index ae5ed142..9ccbda46 100644 --- a/input.c +++ b/input.c @@ -434,19 +434,26 @@ SFORMAT FCEUCTRL_STATEINFO[]={ { 0 } }; - void FCEU_DoSimpleCommand(int cmd) { - switch(cmd) - { - case FCEUNPCMD_FDSINSERT: FCEU_FDSInsert();break; - case FCEUNPCMD_FDSSELECT: FCEU_FDSSelect();break; -// case FCEUNPCMD_FDSEJECT: FCEU_FDSEject();break; - case FCEUNPCMD_VSUNICOIN: FCEU_VSUniCoin(); break; - case FCEUNPCMD_VSUNIDIP0 ... (FCEUNPCMD_VSUNIDIP0 + 7): FCEU_VSUniToggleDIP(cmd - FCEUNPCMD_VSUNIDIP0);break; - case FCEUNPCMD_POWER: PowerNES();break; - case FCEUNPCMD_RESET: ResetNES();break; - } + switch(cmd) + { + case FCEUNPCMD_FDSINSERT: FCEU_FDSInsert();break; + case FCEUNPCMD_FDSSELECT: FCEU_FDSSelect();break; + // case FCEUNPCMD_FDSEJECT: FCEU_FDSEject();break; + case FCEUNPCMD_VSUNICOIN: FCEU_VSUniCoin(); break; + case FCEUNPCMD_VSUNIDIP0: //mbg merge 7/17/06 removed case range syntax + case FCEUNPCMD_VSUNIDIP0+1: + case FCEUNPCMD_VSUNIDIP0+2: + case FCEUNPCMD_VSUNIDIP0+3: + case FCEUNPCMD_VSUNIDIP0+4: + case FCEUNPCMD_VSUNIDIP0+5: + case FCEUNPCMD_VSUNIDIP0+6: + case FCEUNPCMD_VSUNIDIP0+7: + FCEU_VSUniToggleDIP(cmd - FCEUNPCMD_VSUNIDIP0);break; + case FCEUNPCMD_POWER: PowerNES();break; + case FCEUNPCMD_RESET: ResetNES();break; + } } void FCEU_QSimpleCommand(int cmd) @@ -466,10 +473,11 @@ void FCEUI_FDSSelect(void) FCEU_QSimpleCommand(FCEUNPCMD_FDSSELECT); } -int FCEUI_FDSInsert(void) +//mbg merge 7/17/06 changed to void fn(void) to make it an EMUCMDFN +void FCEUI_FDSInsert(void) { FCEU_QSimpleCommand(FCEUNPCMD_FDSINSERT); - return(1); + //return(1); } /* diff --git a/mappers/113.c b/mappers/113.c deleted file mode 100644 index 525f131c..00000000 --- a/mappers/113.c +++ /dev/null @@ -1,64 +0,0 @@ -/* 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" - -/* I'm getting the feeling this is another "jam two different bank - switching hardwares into one mapper". -*/ - -/* HES 4-in-1 */ -DECLFW(Mapper113_write) -{ - ROM_BANK32((V>>3)&7); - VROM_BANK8(((V>>3)&8)|(V&7)); - //printf("$%04x:$%02x\n",A,V); -} - - -/* Deathbots */ -DECLFW(Mapper113_writeh) -{ - //printf("$%04x:$%02x\n",A,V); - // ROM_BANK32(V&0x7); - //VROM_BANK8((V>>4)&0x7); - switch(A) { - case 0x8008: - case 0x8009: - ROM_BANK32(V>>3); - VROM_BANK8(((V>>3)&0x08)+(V&0x07) ); - break; - case 0x8E66: - case 0x8E67: - VROM_BANK8( (V&0x07)?0:1 ); - break; - case 0xE00A: - MIRROR_SET2( 2 ); - break; - } -} - - -void Mapper113_init(void) -{ - ROM_BANK32(0); - SetWriteHandler(0x4020,0x7fff,Mapper113_write); - SetWriteHandler(0x8000,0xffff,Mapper113_writeh); -} diff --git a/mappers/15.c b/mappers/15.c deleted file mode 100644 index e649af6d..00000000 --- a/mappers/15.c +++ /dev/null @@ -1,73 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2003 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 void Sync(void) -{ - int x; - - setmirror(((mapbyte1[0]>>6)&1)^1); - switch(mapbyte1[1]&0x3) - { - case 0x0: - for(x=0;x<4;x++) - setprg8(0x8000+x*8192,(((mapbyte1[0]&0x7F)<<1)+x)^(mapbyte1[0]>>7)); - break; - case 0x2: - for(x=0;x<4;x++) - setprg8(0x8000+x*8192,((mapbyte1[0]&0x7F)<<1)+(mapbyte1[0]>>7)); - break; - case 0x1: - case 0x3: - for(x=0;x<4;x++) - { - unsigned int b; - - b=mapbyte1[0]&0x7F; - if(x>=2 && !(mapbyte1[1]&0x2)) - b=0x7F; - setprg8(0x8000+x*8192,(x&1)+((b<<1)^(mapbyte1[0]>>7))); - } - break; - } -} - - -static DECLFW(Mapper15_write) -{ - mapbyte1[0]=V; - mapbyte1[1]=A&3; - Sync(); -} - -static void StateRestore(int version) -{ - Sync(); -} - -void Mapper15_init(void) -{ - mapbyte1[0]=mapbyte1[1]=0; - Sync(); - GameStateRestore=StateRestore; - SetWriteHandler(0x8000,0xFFFF,Mapper15_write); -} - diff --git a/mappers/151.c b/mappers/151.c deleted file mode 100644 index 5d2cb285..00000000 --- a/mappers/151.c +++ /dev/null @@ -1,41 +0,0 @@ -/* 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" - - - -DECLFW(Mapper151_write) -{ - switch(A&0xF000) - { - case 0x8000:ROM_BANK8(0x8000,V);break; - case 0xA000:ROM_BANK8(0xA000,V);break; - case 0xC000:ROM_BANK8(0xC000,V);break; - case 0xe000:VROM_BANK4(0x0000,V);break; - case 0xf000:VROM_BANK4(0x1000,V);break; - } -} - -void Mapper151_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper151_write); -} - diff --git a/mappers/16.c b/mappers/16.c deleted file mode 100644 index fae46804..00000000 --- a/mappers/16.c +++ /dev/null @@ -1,303 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 1998 BERO - * 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 void FP_FASTAPASS(1) BandaiIRQHook(int a) -{ - if(IRQa) - { - IRQCount-=a; - if(IRQCount<0) - { - X6502_IRQBegin(FCEU_IQEXT); - //printf("IRQ: %d, %d\n",scanline,timestamp); - IRQa=0; - IRQCount=0xFFFF; - } - } -} - -static DECLFW(Mapper16_write) -{ - A&=0xF; - - if(A<=0x7) - VROM_BANK1(A<<10,V); - else if(A==0x8) - ROM_BANK16(0x8000,V); - else switch(A) { - case 0x9: switch(V&3) { - case 0x00:MIRROR_SET2(1);break; - case 0x01:MIRROR_SET2(0);break; - case 0x02:onemir(0);break; - case 0x03:onemir(1);break; - } - break; - case 0xA:X6502_IRQEnd(FCEU_IQEXT); - IRQa=V&1; - IRQCount=IRQLatch; - break; - case 0xB:IRQLatch&=0xFF00; IRQLatch|=V; - break; - case 0xC:IRQLatch&=0xFF; IRQLatch|=V<<8; - break; - case 0xD: break;/* Serial EEPROM control port */ - } -} - -// Famicom jump 2: -// 0-7: Lower bit of data selects which 256KB PRG block is in use. -// This seems to be a hack on the developers' part, so I'll make emulation -// of it a hack(I think the current PRG block would depend on whatever the -// lowest bit of the CHR bank switching register that corresponds to the -// last CHR address read). - -static void PRGO(void) -{ - uint32 base=(mapbyte1[0]&1)<<4; - ROM_BANK16(0x8000,(mapbyte2[0]&0xF)|base); - ROM_BANK16(0xC000,base|0xF); -} - -static DECLFW(Mapper153_write) -{ - A&=0xF; - if(A<=0x7) - { - mapbyte1[A&7]=V; - PRGO(); - } - else if(A==0x8) - { - mapbyte2[0]=V; - PRGO(); - } - else switch(A) { - case 0x9: switch(V&3) { - case 0x00:MIRROR_SET2(1);break; - case 0x01:MIRROR_SET2(0);break; - case 0x02:onemir(0);break; - case 0x03:onemir(1);break; - } - break; - case 0xA:X6502_IRQEnd(FCEU_IQEXT); - IRQa=V&1; - IRQCount=IRQLatch; - break; - case 0xB:IRQLatch&=0xFF00; - IRQLatch|=V; - break; - case 0xC:IRQLatch&=0xFF; - IRQLatch|=V<<8; - break; - } -} - -void Mapper16_init(void) -{ - MapIRQHook=BandaiIRQHook; - SetWriteHandler(0x6000,0xFFFF,Mapper16_write); -} - -void Mapper153_init(void) -{ - MapIRQHook=BandaiIRQHook; - SetWriteHandler(0x8000,0xFFFF,Mapper153_write); - /* This mapper/board seems to have WRAM at $6000-$7FFF, so I'll let the - main ines code take care of that memory region. */ -} - - -static uint8 BarcodeData[256]; -static int BarcodeReadPos; -static int BarcodeCycleCount; -static uint32 BarcodeOut; - -int FCEUI_DatachSet(const uint8 *rcode) -{ - int prefix_parity_type[10][6] = { - {0,0,0,0,0,0}, {0,0,1,0,1,1}, {0,0,1,1,0,1}, {0,0,1,1,1,0}, - {0,1,0,0,1,1}, {0,1,1,0,0,1}, {0,1,1,1,0,0}, {0,1,0,1,0,1}, - {0,1,0,1,1,0}, {0,1,1,0,1,0} - }; - int data_left_odd[10][7] = { - {0,0,0,1,1,0,1}, {0,0,1,1,0,0,1}, {0,0,1,0,0,1,1}, {0,1,1,1,1,0,1}, - {0,1,0,0,0,1,1}, {0,1,1,0,0,0,1}, {0,1,0,1,1,1,1}, {0,1,1,1,0,1,1}, - {0,1,1,0,1,1,1}, {0,0,0,1,0,1,1} - }; - int data_left_even[10][7] = { - {0,1,0,0,1,1,1}, {0,1,1,0,0,1,1}, {0,0,1,1,0,1,1}, {0,1,0,0,0,0,1}, - {0,0,1,1,1,0,1}, {0,1,1,1,0,0,1}, {0,0,0,0,1,0,1}, {0,0,1,0,0,0,1}, - {0,0,0,1,0,0,1}, {0,0,1,0,1,1,1} - }; - int data_right[10][7] = { - {1,1,1,0,0,1,0}, {1,1,0,0,1,1,0}, {1,1,0,1,1,0,0}, {1,0,0,0,0,1,0}, - {1,0,1,1,1,0,0}, {1,0,0,1,1,1,0}, {1,0,1,0,0,0,0}, {1,0,0,0,1,0,0}, - {1,0,0,1,0,0,0}, {1,1,1,0,1,0,0} - }; - uint8 code[13+1]; - uint32 tmp_p=0; - int i, j; - int len; - - for(i=len=0;i<13;i++) - { - if(!rcode[i]) break; - - if((code[i]=rcode[i]-'0') > 9) - return(0); - len++; - } - if(len!=13 && len!=12 && len!=8 && len!=7) return(0); - - #define BS(x) BarcodeData[tmp_p]=x;tmp_p++ - - for(j=0;j<32;j++) - { - BS(0x00); - } - - /* Left guard bars */ - BS(1); BS(0); BS(1); - - if(len==13 || len==12) - { - uint32 csum; - - for(i=0;i<6;i++) - if(prefix_parity_type[code[0]][i]) - { - for(j=0;j<7;j++) - { - BS(data_left_even[code[i+1]][j]); - } - } - else - for(j=0;j<7;j++) - { - BS(data_left_odd[code[i+1]][j]); - } - - /* Center guard bars */ - BS(0); BS(1); BS(0); BS(1); BS(0); - - for(i=7;i<12;i++) - for(j=0;j<7;j++) - { - BS(data_right[code[i]][j]); - } - csum=0; - for(i=0;i<12;i++) csum+=code[i]*((i&1)?3:1); - csum=(10-(csum%10))%10; - //printf("%d\n",csum); - for(j=0;j<7;j++) - { - BS(data_right[csum][j]); - } - - } - else if(len==8 || len==7) - { - uint32 csum=0; - - for(i=0;i<7;i++) csum+=(i&1)?code[i]:(code[i]*3); - - csum=(10-(csum%10))%10; - - for(i=0;i<4;i++) - for(j=0;j<7;j++) - { - BS(data_left_odd[code[i]][j]); - } - - - /* Center guard bars */ - BS(0); BS(1); BS(0); BS(1); BS(0); - - for(i=4;i<7;i++) - for(j=0;j<7;j++) - { - BS(data_right[code[i]][j]); - } - - for(j=0;j<7;j++) - { BS(data_right[csum][j]);} - - } - - /* Right guard bars */ - BS(1); BS(0); BS(1); - - for(j=0;j<32;j++) - { - BS(0x00); - } - - BS(0xFF); - #undef BS - BarcodeReadPos=0; - BarcodeOut=0x8; - BarcodeCycleCount=0; - return(1); -} - -static void FP_FASTAPASS(1) BarcodeIRQHook(int a) -{ - BandaiIRQHook(a); - - BarcodeCycleCount+=a; - - if(BarcodeCycleCount >= 1000) - { - BarcodeCycleCount -= 1000; - if(BarcodeData[BarcodeReadPos]==0xFF) - { - BarcodeOut=0; - } - else - { - BarcodeOut=(BarcodeData[BarcodeReadPos]^1)<<3; - BarcodeReadPos++; - } - } -} - -static DECLFR(Mapper157_read) -{ - uint8 ret; - - ret=BarcodeOut; - return(ret); -} - -void Mapper157_init(void) -{ - FCEUGameInfo->cspecial = SIS_DATACH; - MapIRQHook=BarcodeIRQHook; - SetWriteHandler(0x6000,0xFFFF,Mapper16_write); - SetReadHandler(0x6000,0x7FFF,Mapper157_read); - - BarcodeData[0]=0xFF; - BarcodeReadPos=0; - BarcodeOut=0; - BarcodeCycleCount=0; -} diff --git a/mappers/17.c b/mappers/17.c deleted file mode 100644 index 7fae1a82..00000000 --- a/mappers/17.c +++ /dev/null @@ -1,73 +0,0 @@ -/* 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 void FP_FASTAPASS(1) FFEIRQHook(int a) -{ - if(IRQa) - { - IRQCount+=a; - if(IRQCount>=0x10000) - { - X6502_IRQBegin(FCEU_IQEXT); - IRQa=0; - IRQCount=0; - } - } -} - - -DECLFW(Mapper17_write) -{ - switch(A){ - default: - break; - case 0x42FE: - onemir((V>>4)&1); - break; - case 0x42FF: - MIRROR_SET((V>>4)&1); - break; - case 0x4501:IRQa=0;X6502_IRQEnd(FCEU_IQEXT);break; - case 0x4502:IRQCount&=0xFF00;IRQCount|=V;break; - case 0x4503:IRQCount&=0x00FF;IRQCount|=V<<8;IRQa=1;break; - case 0x4504: ROM_BANK8(0x8000,V);break; - case 0x4505: ROM_BANK8(0xA000,V);break; - case 0x4506: ROM_BANK8(0xC000,V);break; - case 0x4507: ROM_BANK8(0xE000,V);break; - case 0x4510: VROM_BANK1(0x0000,V);break; - case 0x4511: VROM_BANK1(0x0400,V);break; - case 0x4512: VROM_BANK1(0x0800,V);break; - case 0x4513: VROM_BANK1(0x0C00,V);break; - case 0x4514: VROM_BANK1(0x1000,V);break; - case 0x4515: VROM_BANK1(0x1400,V);break; - case 0x4516: VROM_BANK1(0x1800,V);break; - case 0x4517: VROM_BANK1(0x1C00,V);break; - } -} - -void Mapper17_init(void) -{ -MapIRQHook=FFEIRQHook; -SetWriteHandler(0x4020,0x5fff,Mapper17_write); -} diff --git a/mappers/18.c b/mappers/18.c deleted file mode 100644 index b682b26e..00000000 --- a/mappers/18.c +++ /dev/null @@ -1,80 +0,0 @@ -/* 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" - -#define K4buf mapbyte2 -#define K4buf2 mapbyte3 - -void FP_FASTAPASS(1) JalecoIRQHook(int a) -{ - if(IRQa && IRQCount) - { - IRQCount-=a; - if(IRQCount<=0) - { - X6502_IRQBegin(FCEU_IQEXT); - IRQCount=0; - IRQa=0; - } - } -} - -DECLFW(Mapper18_write) -{ - A&=0xF003; - if(A>=0x8000 && A<=0x9001) - { - int x=((A>>1)&1)|((A-0x8000)>>11); - - K4buf2[x]&=(0xF0)>>((A&1)<<2); - K4buf2[x]|=(V&0xF)<<((A&1)<<2); - ROM_BANK8(0x8000+(x<<13),K4buf2[x]); - } - else if(A>=0xa000 && A<=0xd003) - { - int x=((A>>1)&1)|((A-0xA000)>>11); - - K4buf[x]&=(0xF0)>>((A&1)<<2); - K4buf[x]|=(V&0xF)<<((A&1)<<2); - VROM_BANK1(x<<10,K4buf[x]); - } - else switch(A) - { - case 0xe000:IRQLatch&=0xFFF0;IRQLatch|=(V&0x0f);break; - case 0xe001:IRQLatch&=0xFF0F;IRQLatch|=(V&0x0f)<<4;break; - case 0xe002:IRQLatch&=0xF0FF;IRQLatch|=(V&0x0f)<<8;break; - case 0xe003:IRQLatch&=0x0FFF;IRQLatch|=(V&0x0f)<<12;break; - case 0xf000:IRQCount=IRQLatch; - break; - case 0xf001:IRQa=V&1; - X6502_IRQEnd(FCEU_IQEXT); - break; - case 0xf002:MIRROR_SET2(V&1); - if(V&2) onemir(0); - break; - } -} - -void Mapper18_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper18_write); - MapIRQHook=JalecoIRQHook; -} diff --git a/mappers/180.c b/mappers/180.c deleted file mode 100644 index bd877c81..00000000 --- a/mappers/180.c +++ /dev/null @@ -1,14 +0,0 @@ -#include "mapinc.h" - - - -DECLFW(Mapper180_write) -{ -ROM_BANK16(0xC000,V); -} - -void Mapper180_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper180_write); -} - diff --git a/mappers/183.c b/mappers/183.c deleted file mode 100644 index e69de29b..00000000 diff --git a/mappers/184.c b/mappers/184.c deleted file mode 100644 index 70fd6b17..00000000 --- a/mappers/184.c +++ /dev/null @@ -1,15 +0,0 @@ -#include "mapinc.h" - - - -DECLFW(Mapper184_write) -{ -VROM_BANK4(0x0000,V); -VROM_BANK4(0x1000,(V>>4)); -} - -void Mapper184_init(void) -{ - SetWriteHandler(0x6000,0xffff,Mapper184_write); -} - diff --git a/mappers/193.c b/mappers/193.c deleted file mode 100644 index 0afa2475..00000000 --- a/mappers/193.c +++ /dev/null @@ -1,20 +0,0 @@ -#include "mapinc.h" - -static DECLFW(m193w) -{ - //printf("$%04x:$%02x\n",A,V); - switch(A&3) - { - case 0:VROM_BANK4(0x0000,V>>2);break; - case 1:VROM_BANK2(0x1000,V>>1);break; - case 2:VROM_BANK2(0x1800,V>>1);break; - case 3:ROM_BANK8(0x8000,V);break; - } -} - -void Mapper193_init(void) -{ - ROM_BANK32(~0); - SetWriteHandler(0x4018,0x7fff,m193w); - SetReadHandler(0x4018,0x7fff,0); -} diff --git a/mappers/200.c b/mappers/200.c deleted file mode 100644 index ec133084..00000000 --- a/mappers/200.c +++ /dev/null @@ -1,36 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2003 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 DECLFW(Mapper200_write) -{ -// FCEU_printf("%04x, %02x\n",A,V); - ROM_BANK16(0x8000,A&0x07); - ROM_BANK16(0xC000,A&0x07); - VROM_BANK8(A&0x07); - MIRROR_SET((A&0x08)>>3); -} - -void Mapper200_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper200_write); -} - diff --git a/mappers/201.c b/mappers/201.c deleted file mode 100644 index 03e77e69..00000000 --- a/mappers/201.c +++ /dev/null @@ -1,44 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2003 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 DECLFW(Mapper201_write) -{ -// FCEU_printf("%04x, %02x\n",A,V); - if(A&0x08) - { - ROM_BANK32(A&0x03); - VROM_BANK8(A&0x03); - } - else - { - ROM_BANK32(0); - VROM_BANK8(0); - } -} - -void Mapper201_init(void) -{ - ROM_BANK32(0); - VROM_BANK8(0); - SetWriteHandler(0x8000,0xffff,Mapper201_write); -} - diff --git a/mappers/202.c b/mappers/202.c deleted file mode 100644 index cac2a881..00000000 --- a/mappers/202.c +++ /dev/null @@ -1,39 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2003 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 DECLFW(Mapper202_write) -{ - int tmp=(A>>1)&0x7; - - MIRROR_SET(A&1); - ROM_BANK16(0x8000,tmp); - ROM_BANK16(0xc000,tmp+(((tmp&0x6)==0x6)?1:0)); - VROM_BANK8(tmp); -} - -void Mapper202_init(void) -{ - ROM_BANK16(0x8000,0); - ROM_BANK16(0xc000,0); - VROM_BANK8(0); - SetWriteHandler(0x8000,0xFFFF,Mapper202_write); -} diff --git a/mappers/203.c b/mappers/203.c deleted file mode 100644 index 6ab5d520..00000000 --- a/mappers/203.c +++ /dev/null @@ -1,36 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2003 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 DECLFW(Mapper203_write) -{ - ROM_BANK16(0x8000,(V>>2)&3); - ROM_BANK16(0xc000,(V>>2)&3); - VROM_BANK8(V&3); -} - -void Mapper203_init(void) -{ - ROM_BANK16(0x8000,0); - ROM_BANK16(0xc000,0); - VROM_BANK8(0); - SetWriteHandler(0x8000,0xFFFF,Mapper203_write); -} diff --git a/mappers/204.c b/mappers/204.c deleted file mode 100644 index 3d799186..00000000 --- a/mappers/204.c +++ /dev/null @@ -1,38 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2003 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 DECLFW(Mapper204_write) -{ - int tmp2=A&0x6; - int tmp1=tmp2+((tmp2==0x6)?0:(A&1)); - MIRROR_SET((A>>4)&1); - ROM_BANK16(0x8000,tmp1); - ROM_BANK16(0xc000,tmp2+((tmp2==0x6)?1:(A&1))); - VROM_BANK8(tmp1); -} - -void Mapper204_init(void) -{ - ROM_BANK32(~0); - VROM_BANK8(~0); - SetWriteHandler(0x8000,0xFFFF,Mapper204_write); -} diff --git a/mappers/21.c b/mappers/21.c deleted file mode 100644 index 8d60d4c2..00000000 --- a/mappers/21.c +++ /dev/null @@ -1,106 +0,0 @@ -/* 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" - -#define K4buf mapbyte2 -#define K4IRQ mapbyte1[1] -#define K4sel mapbyte1[0] - -static int acount=0; - -DECLFW(Mapper21_write) -{ - A|=((A>>5)&0xF); - - if((A&0xF000)==0xA000) - ROM_BANK8(0xA000,V); - else if((A&0xF000)==0x8000) - { - if(K4sel&2) - ROM_BANK8(0xC000,V); - else - ROM_BANK8(0x8000,V); - } - else if(A>=0xb000 && A<=0xefff) - { - A&=0xF006; - { - int x=((A>>2)&1)|((A-0xB000)>>11); - - K4buf[x]&=(0xF0)>>((A&2)<<1); - K4buf[x]|=(V&0xF)<<((A&2)<<1); - VROM_BANK1(x<<10,K4buf[x]); - } - - } - else switch(A&0xF006) - { - case 0x9000: - switch(V&0x3) - { - case 0:MIRROR_SET(0);break; - case 1:MIRROR_SET(1);break; - case 2:onemir(0);break; - case 3:onemir(1);break; - } - break; - case 0x9006: - case 0x9004: - case 0x9002:if((K4sel&2)!=(V&2)) - { - uint8 swa; - swa=PRGBankList[0]; - ROM_BANK8(0x8000,PRGBankList[2]); - ROM_BANK8(0xc000,swa); - } - K4sel=V; - break; - case 0xf000:IRQLatch&=0xF0;IRQLatch|=V&0xF;break; - case 0xf002:IRQLatch&=0x0F;IRQLatch|=V<<4;break; - case 0xf004:IRQCount=IRQLatch;acount=0; - IRQa=V&2;K4IRQ=V&1; - X6502_IRQEnd(FCEU_IQEXT); - break; - case 0xf006:IRQa=K4IRQ;X6502_IRQEnd(FCEU_IQEXT);break; - } -} -static void FP_FASTAPASS(1) KonamiIRQHook(int a) -{ - #define LCYCS ((227*2)+1) - //#define LCYCS 341 - if(IRQa) - { -// acount+=a*3; - acount+=a*4; - if(acount>=LCYCS) - { - doagainbub:acount-=LCYCS;IRQCount++; - if(IRQCount&0x100) {X6502_IRQBegin(FCEU_IQEXT);IRQCount=IRQLatch;} - if(acount>=LCYCS) goto doagainbub; - } - } -} - -void Mapper21_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper21_write); - MapIRQHook=KonamiIRQHook; -} diff --git a/mappers/212.c b/mappers/212.c deleted file mode 100644 index b069fc3f..00000000 --- a/mappers/212.c +++ /dev/null @@ -1,23 +0,0 @@ -#include "mapinc.h" - -static DECLFW(Mapper212_write) -{ - if((A&0x4000)==0x4000) - { - ROM_BANK32((A&6)>>1); - } - else - { - ROM_BANK16(0x8000,A&7); - ROM_BANK16(0xc000,A&7); - } - VROM_BANK8(A&7); - MIRROR_SET((A>>3)&1); -} - -void Mapper212_init(void) -{ - ROM_BANK32(~0); - VROM_BANK8(~0); - SetWriteHandler(0x8000,0xFFFF,Mapper212_write); -} diff --git a/mappers/213.c b/mappers/213.c deleted file mode 100644 index e0b8d82a..00000000 --- a/mappers/213.c +++ /dev/null @@ -1,14 +0,0 @@ -#include "mapinc.h" - -static DECLFW(Mapper213_write) -{ - ROM_BANK32((A>>1)&3); - VROM_BANK8((A>>3)&7); -} - -void Mapper213_init(void) -{ - ROM_BANK32(0); - VROM_BANK8(0); - SetWriteHandler(0x8000,0xFFFF,Mapper213_write); -} diff --git a/mappers/214.c b/mappers/214.c deleted file mode 100644 index 03a73ce3..00000000 --- a/mappers/214.c +++ /dev/null @@ -1,17 +0,0 @@ -#include "mapinc.h" - -static DECLFW(Mapper214_write) -{ -// FCEU_printf("%02x:%02x\n",A,V); - ROM_BANK16(0x8000,(A>>2)&3); - ROM_BANK16(0xC000,(A>>2)&3); - VROM_BANK8(A&3); -} - -void Mapper214_init(void) -{ - ROM_BANK16(0x8000,0); - ROM_BANK16(0xC000,0); - VROM_BANK8(0); - SetWriteHandler(0x8000,0xFFFF,Mapper214_write); -} diff --git a/mappers/215.c b/mappers/215.c deleted file mode 100644 index 772691c2..00000000 --- a/mappers/215.c +++ /dev/null @@ -1,96 +0,0 @@ -/* -#include "mapinc.h" - -static uint8 cmdin; -static uint8 cmd; -static uint8 regs[8]; -static uint8 master,chrm; - -static void DoPRG215(void) -{ - if(master&0x80) - { - setprg16(0x8000,master&0x1F); - setprg16(0xc000,master&0x1F); - } - else - { - setprg8(0x8000,regs[4]); 6 - setprg8(0xA000,regs[6]); 7 0, 2, 5, 3, 6, 1, 7, 4 - setprg8(0xC000,~1); - setprg8(0xE000,~0); - } - -} - -static void DoCHR215(void) -{ - uint32 base=(cmd&0x80)<<5; - int orie=(chrm&0x4)<<6; - - setchr2(0x0000^base,(orie|regs[0])>>1); 0 - setchr2(0x0800^base,(orie|regs[5])>>1); 1 - - setchr1(0x1000,orie|regs[1]); 2 - setchr1(0x1400,orie|regs[3]); 3 - setchr1(0x1800,orie|regs[7]); 4 - setchr1(0x1c00,orie|regs[2]); 5 -} - -static DECLFW(Write215_write) -{ - switch(A&0xF001) - { - case 0xF001:IRQCount=V+2;break; - case 0xF000:X6502_IRQEnd(FCEU_IQEXT);break; - } - if(A==0x5000) - { - master=V; - DoPRG215(); -// DoCHR215(); - } - else if(A==0x5001) - { - chrm=V; - DoCHR215(); - } - else - switch(A&0xE001) - { - case 0xC000:setmirror(((V|(V>>7))&1)^1);break; - case 0xa000:cmd=V;cmdin=1;DoCHR215();break; - case 0x8001:if(!cmdin) break; - regs[cmd&7]=V; - DoPRG215(); - DoCHR215(); - cmdin=0; - break; - } -} - -static void hooko215(void) -{ - if(IRQCount) - { - IRQCount--; - if(!IRQCount) - { - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -void Mapper215_init(void) -{ - int x; - for(x=0;x<8;x++) regs[x]=0; - master=chrm=cmd=cmdin=IRQCount=0; - GameHBIRQHook=hooko215; - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x5000,0xFFFF,Write215_write); - DoPRG215(); - DoCHR215(); -} - -*/ diff --git a/mappers/217.c b/mappers/217.c deleted file mode 100644 index 6f7a2510..00000000 --- a/mappers/217.c +++ /dev/null @@ -1,96 +0,0 @@ -/* -#include "mapinc.h" - -static uint8 cmdin; -static uint8 cmd; -static uint8 regs[8]; -static uint8 master,chrm; - -static void DoPRG217(void) -{ - if(master&0x80) - { - setprg16(0x8000,master&0x1F); - setprg16(0xc000,master&0x1F); - } - else - { - setprg8(0x8000,regs[1]); - setprg8(0xA000,regs[3]); - setprg8(0xC000,~1); - setprg8(0xE000,~0); - } -} - -static void DoCHR217(void) -{ - uint32 base=(cmd&0x80)<<5; - int orie=(chrm&0x4)<<6; - - setchr2(0x0000^base,(orie|regs[0])>>1); - setchr2(0x0800^base,(orie|regs[7])>>1); - - setchr1(0x1000,orie|regs[5]); - setchr1(0x1400,orie|regs[2]); - setchr1(0x1800,orie|regs[6]); - setchr1(0x1c00,orie|regs[4]); -} - -static DECLFW(Write217_write) -{ -// if(A==0x5000) -// { -// master=V; -// DoPRG217(); -// } -// else if(A==0x5001) -// { -// chrm=V; -// DoCHR217(); -// } -// else if(A==0x5007) -// { -// } - - switch(A&0xE001) - { - case 0x4000:master=V;DoPRG217();break; - case 0x8000:IRQCount=V;break; - case 0xc001:break; - case 0xe000:X6502_IRQEnd(FCEU_IQEXT);break; - case 0xe001:break; - case 0xa001:setmirror((V&1)^1);break; - case 0x8001:cmd=V;cmdin=1;DoPRG217();DoCHR217();break; - case 0xa000:if(!cmdin) break; - regs[cmd&7]=V; - DoPRG217(); - DoCHR217(); - cmdin=0; - break; - } -} - -static void hooko217(void) -{ - if(IRQCount) - { - IRQCount--; - if(!IRQCount) - { - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -void Mapper217_init(void) -{ - int x; - for(x=0;x<8;x++) regs[x]=0; - master=chrm=cmd=cmdin=IRQCount=0; - GameHBIRQHook=hooko217; - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x5000,0xFFFF,Write217_write); - DoPRG217(); - DoCHR217(); -} -*/ \ No newline at end of file diff --git a/mappers/22.c b/mappers/22.c deleted file mode 100644 index 4a080946..00000000 --- a/mappers/22.c +++ /dev/null @@ -1,63 +0,0 @@ -/* 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" - -#define K4buf mapbyte2 - - - -DECLFW(Mapper22_write) -{ - if(A<=0xAFFF) - { - switch(A&0xF000) - { - case 0x8000:ROM_BANK8(0x8000,V);break; - case 0xa000:ROM_BANK8(0xA000,V);break; - case 0x9000:switch(V&3) - { - case 0x00:MIRROR_SET2(1);break; - case 0x01:MIRROR_SET2(0);break; - case 0x02:onemir(0);break; - case 0x03:onemir(1);break; - } - break; - } - } - else - { - A&=0xF003; - if(A>=0xb000 && A<=0xe003) - { - int x=(A&1)|((A-0xB000)>>11); - - K4buf[x]&=(0xF0)>>((A&2)<<1); - K4buf[x]|=(V&0xF)<<((A&2)<<1); - VROM_BANK1(x<<10,K4buf[x]>>1); - } - } -} - - -void Mapper22_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper22_write); -} diff --git a/mappers/225.c b/mappers/225.c deleted file mode 100644 index 14e38f26..00000000 --- a/mappers/225.c +++ /dev/null @@ -1,87 +0,0 @@ -/* 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" - - -#define reg1 mapbyte1[0] -#define reg2 mapbyte1[1] -#define reg3 mapbyte1[2] -#define reg4 mapbyte1[3] - -DECLFR(A110in1read) -{ -switch(A&0x3) - { - case 0:return reg1;break; - case 1:return reg2;break; - case 2:return reg3;break; - case 3:return reg4;break; - } -return 0xF; -} -DECLFW(A110in1regwr) -{ -switch(A&0x3) - { - case 0:reg1=V&0xF;break; - case 1:reg2=V&0xF;break; - case 2:reg3=V&0xF;break; - case 3:reg4=V&0xF;break; - } -} - -DECLFW(Mapper225_write) -{ - int banks=0; - - MIRROR_SET((A>>13)&1); - if(A&0x4000) - banks=1; - else - banks=0; - - VROM_BANK8(((A&0x003f)+(banks<<6))); - if(A&0x1000) - { - if(A&0x40) - { - ROM_BANK16(0x8000,((((((A>>7)&0x1F)+(banks<<5)))<<1)+1)); - ROM_BANK16(0xC000,((((((A>>7)&0x1F)+(banks<<5)))<<1)+1)); - } - else - { - ROM_BANK16(0x8000,(((((A>>7)&0x1F)+(banks<<5)))<<1)); - ROM_BANK16(0xC000,(((((A>>7)&0x1F)+(banks<<5)))<<1)); - } - } - else - { - ROM_BANK32(((((A>>7)&0x1F)+(banks<<5)))); - } -} - -void Mapper225_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper225_write); - SetReadHandler(0x5800,0x5fff,A110in1read); - SetWriteHandler(0x5800,0x5fff,A110in1regwr); -} - diff --git a/mappers/226.c b/mappers/226.c deleted file mode 100644 index bde4f523..00000000 --- a/mappers/226.c +++ /dev/null @@ -1,105 +0,0 @@ -/* 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" - -#define rg mapbyte1 -static void DoPRG(void) -{ - int32 b=((rg[0]>>1)&0xF) | ((rg[0]>>3)&0x10) | ((rg[1]&1)<<5); - if(rg[0]&0x20) // 16 KB - { - ROM_BANK16(0x8000,(b<<1)|(rg[0]&1)); - ROM_BANK16(0xC000,(b<<1)|(rg[0]&1)); - } - else - ROM_BANK32(b); -} - -static DECLFW(Mapper226_write) -{ - rg[A&1]=V; - DoPRG(); - if(A&1) - { - if(rg[1]&2) - PPUCHRRAM=0; // Write protected. - else - PPUCHRRAM=0xFF; // Not write protected. - } - else - MIRROR_SET2((rg[0]>>6)&1); -} - -static void M26Reset(void) -{ - rg[0]=rg[1]=0; - DoPRG(); - PPUCHRRAM=0xFF; - MIRROR_SET2(0); -} - -static void M26Restore(int version) -{ - DoPRG(); - if(rg[1]&2) - PPUCHRRAM=0; // Write protected. - else - PPUCHRRAM=0xFF; // Not write protected. - MIRROR_SET2((rg[0]>>6)&1); -} - -void Mapper226_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper226_write); - MapperReset=M26Reset; - GameStateRestore=M26Restore; - M26Reset(); -} - -#ifdef OLD // What the heck is this?? -DECLFW(Mapper226_write) -{ - MIRROR_SET((A>>13)&1); - VROM_BANK8(A&0x7F); - if(A&0x1000) - { - if(A&0x40) - { - ROM_BANK16(0x8000,(((A>>7))<<1)+1); - ROM_BANK16(0xC000,(((A>>7))<<1)+1); - } - else - { - ROM_BANK16(0x8000,(((A>>7))<<1)); - ROM_BANK16(0xC000,(((A>>7))<<1)); - } - } - else - { - ROM_BANK32(A>>7); - } -} - -void Mapper226_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper226_write); -} -#endif diff --git a/mappers/227.c b/mappers/227.c deleted file mode 100644 index 457e79e2..00000000 --- a/mappers/227.c +++ /dev/null @@ -1,79 +0,0 @@ -/* 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" - -#define rg mapbyte1 - -static void DoSync(uint32 A) -{ - int32 p=((A>>3)&0xF) | ((A>>4)&0x10); - - rg[0]=A; - rg[1]=A>>8; - - MIRROR_SET((A>>1)&1); - if(A&1) //32 KB - { - ROM_BANK32(p); - } - else //16 KB - { - ROM_BANK16(0x8000,(p<<1)|((A&4)>>2)); - ROM_BANK16(0xc000,(p<<1)|((A&4)>>2)); - } - if(A&0x80) - { - PPUCHRRAM=0; - } - else - { - PPUCHRRAM=0xFF; - if(A&0x200) - ROM_BANK16(0xC000,(p<<1)|7); - else - ROM_BANK16(0xC000,(p<<1)&(~7)); - } -} - -static DECLFW(Mapper227_write) -{ - rg[A&1]=V; - DoSync(A); -} - -static void M227Reset(void) -{ - rg[0]=rg[1]=0; - DoSync(0); -} - -static void M227Restore(int version) -{ - DoSync(rg[0]|(rg[1]<<8)); -} - -void Mapper227_init(void) -{ - SetWriteHandler(0x6000,0xffff,Mapper227_write); - MapperReset=M227Reset; - GameStateRestore=M227Restore; - M227Reset(); -} diff --git a/mappers/228.c b/mappers/228.c deleted file mode 100644 index bfae3a63..00000000 --- a/mappers/228.c +++ /dev/null @@ -1,53 +0,0 @@ -/* 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 DECLFW(Mapper228_write) -{ - uint32 page,pagel,pageh; - - MIRROR_SET((A>>13)&1); - - page=(A>>7)&0x3F; - //printf("%04x\n",A); - if((page&0x30)==0x30) - page-=0x10; - - pagel=pageh=(page<<1) + (((A>>6)&1)&((A>>5)&1)); - pageh+=((A>>5)&1)^1; - - ROM_BANK16(0x8000,pagel); - ROM_BANK16(0xC000,pageh); - VROM_BANK8( (V&0x3) | ((A&0xF)<<2) ); -} - -static void A52Reset(void) -{ - Mapper228_write(0,0); -} - -void Mapper228_init(void) -{ - MapperReset=A52Reset; - A52Reset(); - SetWriteHandler(0x8000,0xffff,Mapper228_write); -} - diff --git a/mappers/229.c b/mappers/229.c deleted file mode 100644 index a78dd731..00000000 --- a/mappers/229.c +++ /dev/null @@ -1,48 +0,0 @@ -/* 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" - - - -DECLFW(Mapper229_write) -{ -if(A>=0x8000) -{ -MIRROR_SET((A>>5)&1); -if(!(A&0x1e)) - { - ROM_BANK32(0); - } -else - { - ROM_BANK16(0x8000,A&0x1f); - ROM_BANK16(0xC000,A&0x1f); - } - VROM_BANK8(A); -} - -} - -void Mapper229_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper229_write); -} - diff --git a/mappers/23.c b/mappers/23.c deleted file mode 100644 index d61a5557..00000000 --- a/mappers/23.c +++ /dev/null @@ -1,103 +0,0 @@ -/* 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" - -#define K4buf mapbyte2 -#define K4IRQ mapbyte1[1] -#define K4sel mapbyte1[0] -static int acount=0; -static DECLFW(Mapper23_write) -{ - if((A&0xF000)==0x8000) - { - if(K4sel&2) - ROM_BANK8(0xC000,V); - else - ROM_BANK8(0x8000,V); - } - else if((A&0xF000)==0xA000) - ROM_BANK8(0xA000,V); - else - { - A|=((A>>2)&0x3)|((A>>4)&0x3)|((A>>6)&0x3); - A&=0xF003; - if(A>=0xb000 && A<=0xe003) - { - int x=((A>>1)&1)|((A-0xB000)>>11); - - K4buf[x]&=(0xF0)>>((A&1)<<2); - K4buf[x]|=(V&0xF)<<((A&1)<<2); - VROM_BANK1(x<<10,K4buf[x]); - } - else - switch(A) - { - case 0xf000:X6502_IRQEnd(FCEU_IQEXT);IRQLatch&=0xF0;IRQLatch|=V&0xF;break; - case 0xf001:X6502_IRQEnd(FCEU_IQEXT);IRQLatch&=0x0F;IRQLatch|=V<<4;break; - case 0xf002:X6502_IRQEnd(FCEU_IQEXT);acount=0;IRQCount=IRQLatch;IRQa=V&2;K4IRQ=V&1;break; - case 0xf003:X6502_IRQEnd(FCEU_IQEXT);IRQa=K4IRQ;break; - case 0x9001: - case 0x9002: - case 0x9003: - if((K4sel&2)!=(V&2)) - { - uint8 swa; - swa=PRGBankList[0]; - ROM_BANK8(0x8000,PRGBankList[2]); - ROM_BANK8(0xc000,swa); - } - K4sel=V; - break; - case 0x9000: - if(V!=0xFF) - switch(V&0x3) - { - case 0:MIRROR_SET(0);break; - case 1:MIRROR_SET(1);break; - case 2:onemir(0);break; - case 3:onemir(1);break; - } - break; - } - } -} - -void FP_FASTAPASS(1) KonamiIRQHook2(int a) -{ - #define LCYCS 341 - if(IRQa) - { - acount+=a*3; - if(acount>=LCYCS) - { - doagainbub:acount-=LCYCS;IRQCount++; - if(IRQCount&0x100) {X6502_IRQBegin(FCEU_IQEXT);IRQCount=IRQLatch;} - if(acount>=LCYCS) goto doagainbub; - } - } -} - -void Mapper23_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper23_write); - MapIRQHook=KonamiIRQHook2; -} - diff --git a/mappers/230.c b/mappers/230.c deleted file mode 100644 index cbf1fbe8..00000000 --- a/mappers/230.c +++ /dev/null @@ -1,62 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2003 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" - -#define rom_sw mapbyte1[0] - -void Mapper230_Reset(void) -{ - rom_sw ^= 1; //1 - rom_sw; - - if( rom_sw ) { - ROM_BANK16(0x8000,0); - ROM_BANK16(0xc000,7); - } else { - ROM_BANK16(0x8000,8); - ROM_BANK16(0xc000,39); - } - MIRROR_SET2(1); -} - -static DECLFW(Mapper230_write) -{ - if( rom_sw ) { - ROM_BANK16( 0x8000, V&0x07 ); - } else { - if( V & 0x20 ) { - ROM_BANK16( 0x8000, (V&0x1F)+8 ); - ROM_BANK16( 0xc000, (V&0x1F)+8 ); - } else { - ROM_BANK32( ((V&0x1E) >> 1) + 4 ); - } - MIRROR_SET2( ((V & 0x40) >> 6) ); - } -} - -void Mapper230_init(void) -{ - ROM_BANK16(0x8000,0); - ROM_BANK16(0xc000,7); - SetWriteHandler(0x8000, 0xffff, Mapper230_write); - MapperReset = Mapper230_Reset; - rom_sw = 1; -} - diff --git a/mappers/231.c b/mappers/231.c deleted file mode 100644 index 9b8d1fce..00000000 --- a/mappers/231.c +++ /dev/null @@ -1,41 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2003 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 DECLFW(Mapper231_write) -{ - if(A&0x20) - ROM_BANK32((A>>1)&0xF); - else - { - ROM_BANK16(0x8000,(A&0x1E)); - ROM_BANK16(0xc000,(A&0x1E)); - } - MIRROR_SET((A>>7)&1); -} - -void Mapper231_init(void) -{ - ROM_BANK16(0x8000,0); - ROM_BANK16(0xc000,0); - SetWriteHandler(0x8000,0xffff,Mapper231_write); -} - diff --git a/mappers/232.c b/mappers/232.c deleted file mode 100644 index 548db8c2..00000000 --- a/mappers/232.c +++ /dev/null @@ -1,50 +0,0 @@ -/* 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 void DoIt(void) -{ - ROM_BANK16(0x8000,(mapbyte1[1]&3) | ((mapbyte1[0]&0x18)>>1)); - ROM_BANK16(0xc000,3|(((mapbyte1[0])&0x18)>>1)); -} - -DECLFW(Mapper232_write) -{ - if(A<=0x9FFF) - mapbyte1[0]=V; - else - mapbyte1[1]=V; - DoIt(); -} - -static void QuattroReset(void) -{ - mapbyte1[0]=0x18; - DoIt(); -} - -void Mapper232_init(void) -{ - SetWriteHandler(0x6000,0xffff,Mapper232_write); - MapperReset=QuattroReset; - QuattroReset(); -} - diff --git a/mappers/234.c b/mappers/234.c deleted file mode 100644 index d8ca53ff..00000000 --- a/mappers/234.c +++ /dev/null @@ -1,107 +0,0 @@ -/* 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" - -#define r1 mapbyte1[0] -#define r2 mapbyte1[1] - -static void DoBS(void) -{ - if(r1&0x40) - { - ROM_BANK32((r1&0xE)|(r2&1)); - VROM_BANK8( ((r1&0xE)<<2) | ((r2>>4)&7) ); - } - else - { - ROM_BANK32(r1&0xF); - VROM_BANK8( ((r1&0xF)<<2) | ((r2>>4)&3) ); - } -} - -static void R1Set(uint8 V) -{ - if(r1) return; - r1=V; - MIRROR_SET(V>>7); - DoBS(); -} - -static void R2Set(uint8 V) -{ - r2=V; - DoBS(); -} - -DECLFW(R1W) -{ - R1Set(V); -} - -DECLFR(R1R) -{ - uint8 r=CartBR(A); - R1Set(r); - return r; -} - -DECLFW(R2W) -{ - R2Set(V); -} - -DECLFR(R2R) -{ - uint8 r=CartBR(A); - R2Set(r); - return r; -} - -static void M15Restore(int version) -{ - DoBS(); - MIRROR_SET(r1>>7); -} - -static void M15Reset(void) -{ - r1=r2=0; - DoBS(); - MIRROR_SET(0); -} - -void Mapper234_init(void) -{ - SetWriteHandler(0xff80,0xff9f,R1W); - SetReadHandler(0xff80,0xff9f,R1R); - - SetWriteHandler(0xffe8,0xfff7,R2W); - SetReadHandler(0xffe8,0xfff7,R2R); - - SetReadHandler(0x6000,0x7FFF,0); - SetWriteHandler(0x6000,0x7FFF,0); - - M15Reset(); - - GameStateRestore=M15Restore; - MapperReset=M15Reset; -} - diff --git a/mappers/240.c b/mappers/240.c deleted file mode 100644 index dbbfe192..00000000 --- a/mappers/240.c +++ /dev/null @@ -1,39 +0,0 @@ -/* 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" - - - -DECLFW(Mapper240_write) -{ - if(A<0x8000) - { - ROM_BANK32(V>>4); - VROM_BANK8(V&0xF); - } -} - -void Mapper240_init(void) -{ - SetWriteHandler(0x4020,0x5fff,Mapper240_write); - SetWriteHandler(0x8000,0xffff,Mapper240_write); -} - diff --git a/mappers/241.c b/mappers/241.c deleted file mode 100644 index c0fe7fe6..00000000 --- a/mappers/241.c +++ /dev/null @@ -1,27 +0,0 @@ -#include "mapinc.h" - -static DECLFW(M241wr) -{ -// FCEU_printf("Wr: $%04x:$%02x, $%04x\n",A,V,X.PC); - if(A<0x8000) - { -// printf("$%04x:$%02x, $%04x\n",A,V,X.PC); - } - else - ROM_BANK32(V); -} - -static DECLFR(M241rd) -{ - //DumpMem("out",0x8000,0xffff); - //printf("Rd: $%04x, $%04x\n",A,X.PC); - return(0x50); -} - -void Mapper241_init(void) -{ - ROM_BANK32(0); - SetWriteHandler(0x5000,0x5fff,M241wr); - SetWriteHandler(0x8000,0xFFFF,M241wr); - SetReadHandler(0x4020,0x5fff,M241rd); -} diff --git a/mappers/242.c b/mappers/242.c deleted file mode 100644 index 2fa41710..00000000 --- a/mappers/242.c +++ /dev/null @@ -1,41 +0,0 @@ -/* 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" - - -DECLFW(Mapper242_write) -{ - ROM_BANK32((A>>3)&0xF); - switch(V&3) - { - case 0:MIRROR_SET(0);break; - case 1:MIRROR_SET(1);break; - case 2:onemir(0);break; - case 3:onemir(1);break; - } -} - -void Mapper242_init(void) -{ - ROM_BANK32(0); - SetWriteHandler(0x8000,0xffff,Mapper242_write); -} - diff --git a/mappers/244.c b/mappers/244.c deleted file mode 100644 index 13ea2c1d..00000000 --- a/mappers/244.c +++ /dev/null @@ -1,38 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2003 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 DECLFW(Mapper244_write_1) -{ - ROM_BANK32((A-0x8065)&0x03); -} - -static DECLFW(Mapper244_write_2) -{ - VROM_BANK8((A-0x80A5)&0x07); -} - -void Mapper244_init(void) -{ - ROM_BANK32(0); - SetWriteHandler(0x8065,0x80a4,Mapper244_write_1); - SetWriteHandler(0x80a5,0x80e4,Mapper244_write_2); -} diff --git a/mappers/246.c b/mappers/246.c deleted file mode 100644 index 8623233c..00000000 --- a/mappers/246.c +++ /dev/null @@ -1,44 +0,0 @@ -/* 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" - - -DECLFW(Mapper246_write) -{ - switch(A&0xF007) - { - case 0x6000:ROM_BANK8(0x8000,V);break; - case 0x6001:ROM_BANK8(0xA000,V);break; - case 0x6002:ROM_BANK8(0xC000,V);break; - case 0x6003:ROM_BANK8(0xE000,V);break; - case 0x6004:VROM_BANK2(0x0000,V);break; - case 0x6005:VROM_BANK2(0x0800,V);break; - case 0x6006:VROM_BANK2(0x1000,V);break; - case 0x6007:VROM_BANK2(0x1800,V);break; - } -} - -void Mapper246_init(void) -{ - SetWriteHandler(0x4020,0x67ff,Mapper246_write); - SetWriteHandler(0x8000,0xffff,Mapper246_write); -} - diff --git a/mappers/24and26.c b/mappers/24and26.c deleted file mode 100644 index 0244f45e..00000000 --- a/mappers/24and26.c +++ /dev/null @@ -1,369 +0,0 @@ -/* 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 void (*sfun[3])(void); - -#define vrctemp mapbyte1[0] -#define VPSG2 mapbyte3 -#define VPSG mapbyte2 - -static void DoSQV1(void); -static void DoSQV2(void); -static void DoSawV(void); - -static int swaparoo; - -static int acount=0; - -static void FP_FASTAPASS(1) KonamiIRQHook(int a) -{ - #define LCYCS 341 -// #define LCYCS ((227*2)+1) - if(IRQa) - { - acount+=a*3; - if(acount>=LCYCS) - { - doagainbub:acount-=LCYCS;IRQCount++; - if(IRQCount==0x100) - { - X6502_IRQBegin(FCEU_IQEXT); - IRQCount=IRQLatch; - } - if(acount>=LCYCS) goto doagainbub; - } - } -} - -static DECLFW(VRC6SW) -{ - A&=0xF003; - if(A>=0x9000 && A<=0x9002) - { - VPSG[A&3]=V; - if(sfun[0]) sfun[0](); - } - else if(A>=0xa000 && A<=0xa002) - { - VPSG[4|(A&3)]=V; - if(sfun[1]) sfun[1](); - } - else if(A>=0xb000 && A<=0xb002) - { - VPSG2[A&3]=V; - if(sfun[2]) sfun[2](); - } - -} - -static DECLFW(Mapper24_write) -{ - if(swaparoo) - A=(A&0xFFFC)|((A>>1)&1)|((A<<1)&2); - if(A>=0x9000 && A<=0xb002) - { - VRC6SW(A,V); - return; - } - A&=0xF003; -// if(A>=0xF000) printf("%d, %d, $%04x:$%02x\n",scanline,timestamp,A,V); - switch(A&0xF003) - { - case 0x8000:ROM_BANK16(0x8000,V);break; - case 0xB003: - switch(V&0xF) - { - case 0x0:MIRROR_SET2(1);break; - case 0x4:MIRROR_SET2(0);break; - case 0x8:onemir(0);break; - case 0xC:onemir(1);break; - } - break; - case 0xC000:ROM_BANK8(0xC000,V);break; - case 0xD000:VROM_BANK1(0x0000,V);break; - case 0xD001:VROM_BANK1(0x0400,V);break; - case 0xD002:VROM_BANK1(0x0800,V);break; - case 0xD003:VROM_BANK1(0x0c00,V);break; - case 0xE000:VROM_BANK1(0x1000,V);break; - case 0xE001:VROM_BANK1(0x1400,V);break; - case 0xE002:VROM_BANK1(0x1800,V);break; - case 0xE003:VROM_BANK1(0x1c00,V);break; - case 0xF000:IRQLatch=V; - //acount=0; - break; - case 0xF001:IRQa=V&2; - vrctemp=V&1; - if(V&2) - { - IRQCount=IRQLatch; - acount=0; - } - X6502_IRQEnd(FCEU_IQEXT); - break; - case 0xf002:IRQa=vrctemp; - X6502_IRQEnd(FCEU_IQEXT);break; - case 0xF003:break; - } -} - -static int32 CVBC[3]; -static int32 vcount[3]; -static int32 dcount[2]; - -static INLINE void DoSQV(int x) -{ - int32 V; - int32 amp=(((VPSG[x<<2]&15)<<8)*6/8)>>4; - int32 start,end; - - start=CVBC[x]; - end=(SOUNDTS<<16)/soundtsinc; - if(end<=start) return; - CVBC[x]=end; - - if(VPSG[(x<<2)|0x2]&0x80) - { - if(VPSG[x<<2]&0x80) - { - for(V=start;V>4]+=amp; - } - else - { - int32 thresh=(VPSG[x<<2]>>4)&7; - int32 freq=((VPSG[(x<<2)|0x1]|((VPSG[(x<<2)|0x2]&15)<<8))+1)<<17; - for(V=start;Vthresh) /* Greater than, not >=. Important. */ - Wave[V>>4]+=amp; - vcount[x]-=nesincsize; - while(vcount[x]<=0) /* Should only be <0 in a few circumstances. */ - { - vcount[x]+=freq; - dcount[x]=(dcount[x]+1)&15; - } - } - } - } -} - -static void DoSQV1(void) -{ - DoSQV(0); -} - -static void DoSQV2(void) -{ - DoSQV(1); -} - -static void DoSawV(void) -{ - int V; - int32 start,end; - - start=CVBC[2]; - end=(SOUNDTS<<16)/soundtsinc; - if(end<=start) return; - CVBC[2]=end; - - if(VPSG2[2]&0x80) - { - static int32 saw1phaseacc=0; - uint32 freq3; - static uint8 b3=0; - static int32 phaseacc=0; - static uint32 duff=0; - - freq3=(VPSG2[1]+((VPSG2[2]&15)<<8)+1); - - for(V=start;V>3)&0x1f)<<4)*6/8; - } - Wave[V>>4]+=duff; - } - } -} - -static INLINE void DoSQVHQ(int x) -{ - int32 V; - int32 amp=((VPSG[x<<2]&15)<<8)*6/8; - - if(VPSG[(x<<2)|0x2]&0x80) - { - if(VPSG[x<<2]&0x80) - { - for(V=CVBC[x];V>4)&7; - for(V=CVBC[x];Vthresh) /* Greater than, not >=. Important. */ - WaveHi[V]+=amp; - vcount[x]--; - if(vcount[x]<=0) /* Should only be <0 in a few circumstances. */ - { - vcount[x]=(VPSG[(x<<2)|0x1]|((VPSG[(x<<2)|0x2]&15)<<8))+1; - dcount[x]=(dcount[x]+1)&15; - } - } - } - } - CVBC[x]=SOUNDTS; -} - -static void DoSQV1HQ(void) -{ - DoSQVHQ(0); -} - -static void DoSQV2HQ(void) -{ - DoSQVHQ(1); -} - -static void DoSawVHQ(void) -{ - static uint8 b3=0; - static int32 phaseacc=0; - int32 V; - - if(VPSG2[2]&0x80) - { - for(V=CVBC[2];V>3)&0x1f)<<8)*6/8; - vcount[2]--; - if(vcount[2]<=0) - { - vcount[2]=(VPSG2[1]+((VPSG2[2]&15)<<8)+1)<<1; - phaseacc+=VPSG2[0]&0x3f; - b3++; - if(b3==7) - { - b3=0; - phaseacc=0; - } - - } - } - } - CVBC[2]=SOUNDTS; -} - - -void VRC6Sound(int Count) -{ - int x; - - DoSQV1(); - DoSQV2(); - DoSawV(); - for(x=0;x<3;x++) - CVBC[x]=Count; -} - -void VRC6SoundHQ(void) -{ - DoSQV1HQ(); - DoSQV2HQ(); - DoSawVHQ(); -} - -void VRC6SyncHQ(int32 ts) -{ - int x; - for(x=0;x<3;x++) CVBC[x]=ts; -} - -static void VRC6_ESI(void) -{ - GameExpSound.RChange=VRC6_ESI; - GameExpSound.Fill=VRC6Sound; - GameExpSound.HiFill=VRC6SoundHQ; - GameExpSound.HiSync=VRC6SyncHQ; - - memset(CVBC,0,sizeof(CVBC)); - memset(vcount,0,sizeof(vcount)); - memset(dcount,0,sizeof(dcount)); - if(FSettings.SndRate) - { - if(FSettings.soundq>=1) - { - sfun[0]=DoSQV1HQ; - sfun[1]=DoSQV2HQ; - sfun[2]=DoSawVHQ; - } - else - { - sfun[0]=DoSQV1; - sfun[1]=DoSQV2; - sfun[2]=DoSawV; - } - } - else - memset(sfun,0,sizeof(sfun)); -} - -void Mapper24_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper24_write); - VRC6_ESI(); - MapIRQHook=KonamiIRQHook; - swaparoo=0; -} - -void Mapper26_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper24_write); - VRC6_ESI(); - MapIRQHook=KonamiIRQHook; - swaparoo=1; -} - -void NSFVRC6_Init(void) -{ - VRC6_ESI(); - SetWriteHandler(0x8000,0xbfff,VRC6SW); -} diff --git a/mappers/25.c b/mappers/25.c deleted file mode 100644 index f8c1d73a..00000000 --- a/mappers/25.c +++ /dev/null @@ -1,100 +0,0 @@ -/* 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" - -#define K4buf mapbyte2 -#define K4IRQ mapbyte1[1] -#define K4sel mapbyte1[0] - -static int acount=0; -static DECLFW(Mapper25_write) -{ - A=(A&0xF003)|((A&0xC)>>2); - - if((A&0xF000)==0xA000) - ROM_BANK8(0xA000,V); - else if(A>=0xB000 && A<=0xEFFF) - { - int x=(A&1)|((A-0xB000)>>11); - - K4buf[x]&=(0xF0)>>((A&2)<<1); - K4buf[x]|=(V&0xF)<<((A&2)<<1); - VROM_BANK1(x<<10,K4buf[x]); - } - else if((A&0xF000)==0x8000) - { - if(K4sel&2) - ROM_BANK8(0xC000,V); - else - ROM_BANK8(0x8000,V); - } - else switch(A) - { - case 0x9000:switch(V&0x3) - { - case 0:MIRROR_SET(0);break; - case 1:MIRROR_SET(1);break; - case 2:onemir(0);break; - case 3:onemir(1);break; - } - break; - case 0x9001:if((K4sel&2)!=(V&2)) - { - uint8 swa; - swa=PRGBankList[0]; - ROM_BANK8(0x8000,PRGBankList[2]); - ROM_BANK8(0xc000,swa); - } - K4sel=V; - break; - case 0xf000:IRQLatch&=0xF0;IRQLatch|=V&0xF;break; - case 0xf002:IRQLatch&=0x0F;IRQLatch|=V<<4;break; - case 0xf001:IRQCount=IRQLatch;IRQa=V&2;K4IRQ=V&1;acount=0;X6502_IRQEnd(FCEU_IQEXT);break; - case 0xf003:IRQa=K4IRQ;X6502_IRQEnd(FCEU_IQEXT);break; - } -} - -static void FP_FASTAPASS(1) KonamiIRQHook(int a) -{ -// #define LCYCS ((227*2)) - #define LCYCS 341 - if(IRQa) - { - acount+=a*3; - // acount+=a*4; - if(acount>=LCYCS) - { - doagainbub:acount-=LCYCS;IRQCount++; - if(IRQCount&0x100) - {//acount=0; - X6502_IRQBegin(FCEU_IQEXT);IRQCount=IRQLatch; - } - if(acount>=LCYCS) goto doagainbub; - } - } -} - -void Mapper25_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper25_write); - MapIRQHook=KonamiIRQHook; -} - diff --git a/mappers/255.c b/mappers/255.c deleted file mode 100644 index d65f18da..00000000 --- a/mappers/255.c +++ /dev/null @@ -1,67 +0,0 @@ -/* 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 DECLFW(Mapper255_write) -{ - uint32 pbank=(A>>7)&0x1F; - uint32 cbank=A&0x3F; - uint32 rbank=(A>>14)&1; - -// printf("$%04x:$%02x\n",A,V); -// printf("%2x:%2x:%2x,%2x\n",pbank,cbank,rbank,(A&0x40)>>6); - - if(A&0x1000) - { - ROM_BANK16(0x8000,((pbank|(rbank<<5))<<1)|((A&0x40)>>6)); - ROM_BANK16(0xc000,((pbank|(rbank<<5))<<1)|((A&0x40)>>6)); - } - else - { - ROM_BANK32(pbank|(rbank<<5)); - } - MIRROR_SET((A>>13)&1); - VROM_BANK8((rbank<<6)|cbank); -} - -static DECLFW(Mapper255_wl) -{ -// printf("Wr: $%04x:$%02x\n",A,V); - mapbyte1[A&3]=V&0xF; -} - -static DECLFR(Mapper255_read) -{ - //printf("Rd: $%04x\n",A); - return(mapbyte1[A&3]); //|(X.DB&0xF0)); -} - -void Mapper255_init(void) -{ - mapbyte1[0]=mapbyte1[1]=0xF; - ROM_BANK32(0); - VROM_BANK8(0); - SetWriteHandler(0x5800,0x5FF0,Mapper255_wl); - SetWriteHandler(0x8000,0xffff,Mapper255_write); - SetReadHandler(0x5800,0x5FFF,Mapper255_read); -} diff --git a/mappers/27.c b/mappers/27.c deleted file mode 100644 index 9dbe5cf2..00000000 --- a/mappers/27.c +++ /dev/null @@ -1,74 +0,0 @@ -#include "mapinc.h" - -static uint32 regchr[9]; - -static DECLFW(Mapper27_write) -{ - A&=0xF00F; - int regnum; - if((A>=0xB000) && (A<=0xE003)) { - regnum=((((A>>12)+1)&0x03)<<1)|((A&0x02)>>1); - if(A&1) - regchr[regnum]=(regchr[regnum]&0x0F)|(V<<4); - else - regchr[regnum]=(regchr[regnum]&0xFF0)|(V&0xF); - VROM_BANK1(regnum<<10,regchr[regnum]); - } - switch(A) - { - case 0x8000: if(regchr[8]&2) - ROM_BANK8(0xc000,V); - else - ROM_BANK8(0x8000,V); - break; - case 0xA000: ROM_BANK8(0xa000,V); break; - case 0x9000: - switch(V&3){ - case 0:setmirror(MI_V);break; - case 1:setmirror(MI_H);break; - case 2:setmirror(MI_0);break; - case 3:setmirror(MI_1);break; - } - case 0x9002: regchr[8]=V; break; - case 0xF000: //X6502_IRQEnd(FCEU_IQEXT); - IRQLatch=(IRQLatch&0xF0)|(V&0x0F); - break; - case 0xF001: //X6502_IRQEnd(FCEU_IQEXT); - IRQLatch=(IRQLatch&0x0F)|((V&0xF)<<4); - break; - case 0xF003: IRQa=((IRQa&0x1)<<1)|(IRQa&0x1); - X6502_IRQEnd(FCEU_IQEXT); - break; - case 0xF002: IRQa=V&3; - if(IRQa&0x02) IRQCount=IRQLatch; - X6502_IRQEnd(FCEU_IQEXT); - break; - } -// if((A&0xF000)==0xF000) FCEU_printf("$%04x:$%02x, %d\n",A,V, scanline); -} - -static void Mapper27_hb(void) -{ -// FCEU_printf("%02x-%d,%d,%d\n",scanline,IRQa,IRQCount,IRQLatch); - if(IRQa&0x2){ - if(IRQCount==0xFF){ - X6502_IRQBegin(FCEU_IQEXT); - IRQCount=IRQLatch+1; - } else { - IRQCount++; - } - } -} - -void Mapper27_init(void) -{ - int i; - for (i=0; i<9; i++) { - regchr[i]=0; - } - IRQa=0; - IRQCount=IRQLatch=0; - SetWriteHandler(0x8000,0xffff,Mapper27_write); - GameHBIRQHook=Mapper27_hb; -} - diff --git a/mappers/32.c b/mappers/32.c deleted file mode 100644 index 13e4bba9..00000000 --- a/mappers/32.c +++ /dev/null @@ -1,53 +0,0 @@ -/* 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" - - -#define IREMCon mapbyte1[0] - -static DECLFW(Mapper32_write) -{ - switch(A>>12) - { - case 0x8: - mapbyte1[1]=V; - if(IREMCon) {ROM_BANK8(0xc000,V);ROM_BANK8(0x8000,~1);} - else {ROM_BANK8(0x8000,V);ROM_BANK8(0xc000,~1);} - break; - case 0x9:IREMCon=(V>>1)&1; - if(IREMCon) {ROM_BANK8(0xc000,mapbyte1[1]);ROM_BANK8(0x8000,~1);} - else {ROM_BANK8(0x8000,mapbyte1[1]); ROM_BANK8(0xc000,~1);} - MIRROR_SET(V&1); - break; - case 0xa:ROM_BANK8(0xA000,V); - break; - } - - if((A&0xF000)==0xb000) - VROM_BANK1((A&0x7)<<10,V); -} - -void Mapper32_init(void) -{ - ROM_BANK16(0x8000,0); - ROM_BANK16(0xc000,~0); - SetWriteHandler(0x8000,0xffff,Mapper32_write); -} diff --git a/mappers/33.c b/mappers/33.c deleted file mode 100644 index f3362c01..00000000 --- a/mappers/33.c +++ /dev/null @@ -1,80 +0,0 @@ -/* 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 int is48; - -static DECLFW(Mapper33_write) -{ - //printf("%04x:%02x, %d\n",A,V,scanline); - - A&=0xF003; - if(A>=0xA000 && A<=0xA003) - VROM_BANK1(0x1000+((A&3)<<10),V); - else switch(A) - { - case 0x8000:if(!is48) MIRROR_SET((V>>6)&1); - ROM_BANK8(0x8000,V); - break; - case 0x8001:ROM_BANK8(0xA000,V); break; - case 0x8002:VROM_BANK2(0x0000,V);break; - case 0x8003:VROM_BANK2(0x0800,V);break; - } -} - -static DECLFW(Mapper48_HiWrite) -{ - switch(A&0xF003) - { - case 0xc000:IRQLatch=V;break; - case 0xc001:IRQCount=IRQLatch;break; - case 0xc003:IRQa=0;X6502_IRQEnd(FCEU_IQEXT);break; - case 0xc002:IRQa=1;break; - case 0xe000:MIRROR_SET((V>>6)&1);break; - } -} - -static void heho(void) -{ - if(IRQa) - { - IRQCount++; - if(IRQCount==0x100) - { - X6502_IRQBegin(FCEU_IQEXT); - IRQa=0; - } - } -} - -void Mapper33_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper33_write); - is48=0; -} - -void Mapper48_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper33_write); - SetWriteHandler(0xc000,0xffff,Mapper48_HiWrite); - GameHBIRQHook=heho; - is48=1; -} diff --git a/mappers/40.c b/mappers/40.c deleted file mode 100644 index 471a7cc3..00000000 --- a/mappers/40.c +++ /dev/null @@ -1,58 +0,0 @@ -/* 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 DECLFW(Mapper40_write) -{ - switch(A&0xe000) - { - case 0x8000:IRQa=0;IRQCount=0;X6502_IRQEnd(FCEU_IQEXT);break; - case 0xa000:IRQa=1;break; - case 0xe000:ROM_BANK8(0xc000,V&7);break; - } -} - -static void FP_FASTAPASS(1) Mapper40IRQ(int a) -{ - if(IRQa) - { - if(IRQCount<4096) - IRQCount+=a; - else - { - IRQa=0; - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -void Mapper40_init(void) -{ - ROM_BANK8(0x6000,(~0)-1); - ROM_BANK8(0x8000,(~0)-3); - ROM_BANK8(0xa000,(~0)-2); - SetWriteHandler(0x8000,0xffff,Mapper40_write); - SetReadHandler(0x6000,0x7fff,CartBR); - MapIRQHook=Mapper40IRQ; -} - - diff --git a/mappers/41.c b/mappers/41.c deleted file mode 100644 index dfb69089..00000000 --- a/mappers/41.c +++ /dev/null @@ -1,57 +0,0 @@ -/* 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" - - -#define calreg mapbyte1[0] -#define calchr mapbyte1[1] - -DECLFW(Mapper41_write) -{ - if(A<0x8000) - { - ROM_BANK32(A&7); - MIRROR_SET((A>>5)&1); - calreg=A; - calchr&=0x3; - calchr|=(A>>1)&0xC; - VROM_BANK8(calchr); - } - else if(calreg&0x4) - { - calchr&=0xC; - calchr|=A&3; - VROM_BANK8(calchr); - } -} - -static void M41Reset(void) -{ - calreg=calchr=0; -} - -void Mapper41_init(void) -{ - MapperReset=M41Reset; - ROM_BANK32(0); - SetWriteHandler(0x8000,0xffff,Mapper41_write); - SetWriteHandler(0x6000,0x67ff,Mapper41_write); -} diff --git a/mappers/42.c b/mappers/42.c deleted file mode 100644 index bf31ac29..00000000 --- a/mappers/42.c +++ /dev/null @@ -1,64 +0,0 @@ -/* 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 DECLFW(Mapper42_write) -{ -// FCEU_printf("%04x:%04x\n",A,V); - switch(A&0xe003) - { - case 0x8000:VROM_BANK8(V);break; - case 0xe000:mapbyte1[0]=V;ROM_BANK8(0x6000,V&0xF);break; - case 0xe001:MIRROR_SET((V>>3)&1);break; - case 0xe002:IRQa=V&2;if(!IRQa) IRQCount=0;X6502_IRQEnd(FCEU_IQEXT);break; - } -} - -static void FP_FASTAPASS(1) Mapper42IRQ(int a) -{ - if(IRQa) - { - IRQCount+=a; - if(IRQCount>=32768) IRQCount-=32768; - if(IRQCount>=24576) - X6502_IRQBegin(FCEU_IQEXT); - else - X6502_IRQEnd(FCEU_IQEXT); - } -} - -static void Mapper42_StateRestore(int version) -{ - ROM_BANK8(0x6000,mapbyte1[0]&0xF); -} - - -void Mapper42_init(void) -{ - ROM_BANK8(0x6000,0); - ROM_BANK32(~0); - SetWriteHandler(0x6000,0xffff,Mapper42_write); - SetReadHandler(0x6000,0x7fff,CartBR); - MapStateRestore=Mapper42_StateRestore; - MapIRQHook=Mapper42IRQ; -} - diff --git a/mappers/43.c b/mappers/43.c deleted file mode 100644 index ef7d40d7..00000000 --- a/mappers/43.c +++ /dev/null @@ -1,76 +0,0 @@ -/* 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 DECLFW(Mapper43_write) -{ - //printf("$%04x:$%02x\n",A,V); - if((A&0x8122)==0x8122) - { - X6502_IRQEnd(FCEU_IQEXT); - if(V&2) IRQa=1; - else - IRQCount=IRQa=0; - } -} - -static DECLFW(M43Low) -{ -// int transo[8]={4,3,4,4,4,7,5,6}; - int transo[8]={4,3,2,3,4,7,5,6}; - A&=0xF0FF; - if(A==0x4022) - setprg8(0x6000,transo[V&7]); - //printf("$%04x:$%02x\n",A,V); -} - -static void FP_FASTAPASS(1) M43Ho(int a) -{ - IRQCount+=a; - if(IRQa) - if(IRQCount>=4096) - { - X6502_IRQBegin(FCEU_IQEXT); - } -} - -//static DECLFR(boo) -//{ -// printf("$%04x\n",A); -// return( ROM[0x2000*8 +0x1000 +(A-0x5000)]); -//} - -void Mapper43_init(void) -{ - setprg4(0x5000,16); - setprg8(0x6000,2); - setprg8(0x8000,1); - setprg8(0xa000,0); - setprg8(0xc000,4); - setprg8(0xe000,9); - SetWriteHandler(0x8000,0xffff,Mapper43_write); - SetWriteHandler(0x4020,0x7fff,M43Low); - //SetReadHandler(0x5000,0x5fff,boo); - SetReadHandler(0x6000,0xffff,CartBR); - MapIRQHook=M43Ho; -} diff --git a/mappers/46.c b/mappers/46.c deleted file mode 100644 index 8c4ef6d3..00000000 --- a/mappers/46.c +++ /dev/null @@ -1,48 +0,0 @@ -/* 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" - - - -#define A64reg mapbyte1[0] -#define A64wr mapbyte1[1] - -DECLFW(Mapper46_writel) -{ - A64reg=V; - ROM_BANK32((A64wr&1)+((A64reg&0xF)<<1)); - VROM_BANK8(((A64wr>>4)&7)+((A64reg&0xF0)>>1)); -} - -DECLFW(Mapper46_write) -{ - A64wr=V; - ROM_BANK32((V&1)+((A64reg&0xF)<<1)); - VROM_BANK8(((V>>4)&7)+((A64reg&0xF0)>>1)); -} - -void Mapper46_init(void) -{ - MIRROR_SET(0); - ROM_BANK32(0); - SetWriteHandler(0x8000,0xffff,Mapper46_write); - SetWriteHandler(0x6000,0x7fff,Mapper46_writel); -} diff --git a/mappers/50.c b/mappers/50.c deleted file mode 100644 index 8d7f515f..00000000 --- a/mappers/50.c +++ /dev/null @@ -1,75 +0,0 @@ -/* 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 void FP_FASTAPASS(1) Mapper50IRQ(int a) -{ - if(IRQa) - { - if(IRQCount<4096) - IRQCount+=a; - else - { - IRQa=0; - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -static void M50Restore(int version) -{ - setprg8(0xc000,mapbyte1[0]); -} - -static DECLFW(M50W) -{ - if((A&0xD060)==0x4020) - { - if(A&0x100) - { - IRQa=V&1; - if(!IRQa) IRQCount=0; - X6502_IRQEnd(FCEU_IQEXT); - } - else - { - V=((V&1)<<2)|((V&2)>>1)|((V&4)>>1)|(V&8); - mapbyte1[0]=V; - setprg8(0xc000,V); - } - } -} - -void Mapper50_init(void) -{ - SetWriteHandler(0x4020,0x5fff,M50W); - SetReadHandler(0x6000,0xffff,CartBR); - MapStateRestore=M50Restore; - MapIRQHook=Mapper50IRQ; - - setprg8(0x6000,0xF); - setprg8(0x8000,0x8); - setprg8(0xa000,0x9); - setprg8(0xc000,0x0); - setprg8(0xe000,0xB); -} - diff --git a/mappers/51.c b/mappers/51.c deleted file mode 100644 index cc1fbbdc..00000000 --- a/mappers/51.c +++ /dev/null @@ -1,66 +0,0 @@ -/* 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" - -#define mode mapbyte1[0] -#define page mapbyte1[1] - -static uint32 Get8K(uint32 A) -{ - uint32 bank; - - bank=(page<<2)|((A>>13)&1); - - if(A&0x4000 && !(mode&1)) bank|=0xC; - if(!(A&0x8000)) bank|=0x20; - if(mode==2) bank|=2; - else bank|=(A>>13)&2; - return(bank); -} - -static void Synco(void) -{ - uint32 x; - if(mapbyte1[0]<=2) - MIRROR_SET2(1); - else - MIRROR_SET2(0); - for(x=0x6000;x<0x10000;x+=8192) - ROM_BANK8(x,Get8K(x)); -} - -static DECLFW(Write) -{ - if(A&0x8000) mapbyte1[1]=V&0xF; - else mapbyte1[0]=(mapbyte1[0]&2)|((V>>1)&1); - - if(A&0x4000) mapbyte1[0]=(mapbyte1[0]&1)|((V>>3)&2); - Synco(); -} - -void Mapper51_init(void) -{ - SetWriteHandler(0x6000,0xFFFF,Write); - SetReadHandler(0x6000,0xFFFF,CartBR); - mapbyte1[0]=1; - mapbyte1[1]=0; - Synco(); -} diff --git a/mappers/59.c b/mappers/59.c deleted file mode 100644 index 30ddb8b4..00000000 --- a/mappers/59.c +++ /dev/null @@ -1,47 +0,0 @@ -/* 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 int ay; -static DECLFW(Mapper59_write) -{ - //printf("$%04x:$%02x\n",A,V); - setprg32(0x8000,(A&0x70)>>4); - setchr8(A&0x7); - //if(A&0x100) - // setprg32r(0x10,0x8000,0); - ay=A; - MIRROR_SET2((A&0x8)>>3); -} - -static DECLFR(m59rd) -{ - if(ay&0x100) return(0); - else - return(CartBR(A)); -} - -void Mapper59_init(void) -{ - setprg32(0x8000,0); - SetReadHandler(0x8000,0xffff,m59rd); - SetWriteHandler(0x8000,0xffff,Mapper59_write); -} diff --git a/mappers/6.c b/mappers/6.c deleted file mode 100644 index c6c5bf5c..00000000 --- a/mappers/6.c +++ /dev/null @@ -1,80 +0,0 @@ -/* 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 FFEmode; - -#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;} - -static void FP_FASTAPASS(1) FFEIRQHook(int a) -{ - if(IRQa) - { - IRQCount+=a; - if(IRQCount>=0x10000) - { - X6502_IRQBegin(FCEU_IQEXT); - IRQa=0; - IRQCount=0; - } - } -} - -DECLFW(Mapper6_write) -{ - if(A<0x8000) - { - switch(A){ - case 0x42FF:MIRROR_SET((V>>4)&1);break; - case 0x42FE:onemir((V>>3)&2); FFEmode=V&0x80;break; - case 0x4501:IRQa=0;X6502_IRQEnd(FCEU_IQEXT);break; - case 0x4502:IRQCount&=0xFF00;IRQCount|=V;break; - case 0x4503:IRQCount&=0xFF;IRQCount|=V<<8;IRQa=1;break; - } - } else { - switch (FFEmode) - { - case 0x80: setchr8(V); break; - default: ROM_BANK16(0x8000,V>>2); - FVRAM_BANK8(0x0000,V&3); - } - } -} -void Mapper6_StateRestore(int version) -{ - int x; - for(x=0;x<8;x++) - if(PPUCHRRAM&(1<7) - VPage[x]=&MapperExRAM[(CHRBankList[x]&31)*0x400]-(x*0x400); - else VPage[x]=&CHRRAM[(CHRBankList[x]&7)*0x400]-(x*0x400); - } -} -void Mapper6_init(void) -{ -MapIRQHook=FFEIRQHook; -ROM_BANK16(0xc000,7); - -SetWriteHandler(0x4020,0x5fff,Mapper6_write); -SetWriteHandler(0x8000,0xffff,Mapper6_write); -MapStateRestore=Mapper6_StateRestore; -} diff --git a/mappers/60.c b/mappers/60.c deleted file mode 100644 index b48087ca..00000000 --- a/mappers/60.c +++ /dev/null @@ -1,41 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2003 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 DECLFW(Mapper60_write) -{ - if(A&0x80) { - ROM_BANK16(0x8000,(A&0x70)>>4); - ROM_BANK16(0xC000,(A&0x70)>>4); - } - else - ROM_BANK32((A&0x70)>>5); - VROM_BANK8(A&7); - MIRROR_SET((A&8)>>3); -} - -void Mapper60_init(void) -{ - ROM_BANK32(0); - SetWriteHandler(0x8000,0xffff, Mapper60_write); -} - - diff --git a/mappers/61.c b/mappers/61.c deleted file mode 100644 index 43039329..00000000 --- a/mappers/61.c +++ /dev/null @@ -1,54 +0,0 @@ -/* 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 DECLFW(Mapper61_write) -{ -// printf("$%04x:$%02x\n",A,V); - switch(A&0x30) - { - case 0x00: - case 0x30: - ROM_BANK32(A&0xF); - break; - case 0x20: - case 0x10: - ROM_BANK16(0x8000,((A&0xF)<<1)| (((A&0x20)>>4)) ); - ROM_BANK16(0xC000,((A&0xF)<<1)| (((A&0x20)>>4)) ); - break; - } - #ifdef moo - if(!(A&0x10)) - ROM_BANK32(A&0xF); - else - { - ROM_BANK16(0x8000,((A&0xF)<<1)| (((A&0x10)>>4)^1) ); - ROM_BANK16(0xC000,((A&0xF)<<1)| (((A&0x10)>>4)^1) ); - } - #endif - MIRROR_SET((A&0x80)>>7); -} - -void Mapper61_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper61_write); -} diff --git a/mappers/62.c b/mappers/62.c deleted file mode 100644 index 4d03c887..00000000 --- a/mappers/62.c +++ /dev/null @@ -1,41 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2003 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 DECLFW(Mapper62_write) -{ - VROM_BANK8(((A&0x1F)<<2)|(V&0x03)); - if(A&0x20) { - ROM_BANK16(0x8000,(A&0x40)|((A>>8)&0x3F)); - ROM_BANK16(0xc000,(A&0x40)|((A>>8)&0x3F)); - } - else - ROM_BANK32(((A&0x40)|((A>>8)&0x3F))>>1); - MIRROR_SET((A&0x80)>>7); -} - -void Mapper62_init(void) -{ - SetWriteHandler(0x8000,0xffff, Mapper62_write); - ROM_BANK32(0); -} - - diff --git a/mappers/65.c b/mappers/65.c deleted file mode 100644 index d8176943..00000000 --- a/mappers/65.c +++ /dev/null @@ -1,74 +0,0 @@ -/* 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" - - -void FP_FASTAPASS(1) IREMIRQHook(int a) -{ - if(IRQa) - { - IRQCount-=a; - if(IRQCount<-4) - { - X6502_IRQBegin(FCEU_IQEXT); - IRQa=0; - IRQCount=0xFFFF; - } - } -} - -static DECLFW(Mapper65_write) -{ - //if(A>=0x9000 && A<=0x9006) - // printf("$%04x:$%02x, %d\n",A,V,scanline); - switch(A) - { - //default: printf("$%04x:$%02x\n",A,V); - // break; - case 0x8000:ROM_BANK8(0x8000,V);break; - // case 0x9000:printf("$%04x:$%02x\n",A,V);MIRROR_SET2((V>>6)&1);break; - case 0x9001:MIRROR_SET(V>>7);break; - case 0x9003:IRQa=V&0x80;X6502_IRQEnd(FCEU_IQEXT);break; - case 0x9004:IRQCount=IRQLatch;break; - case 0x9005: IRQLatch&=0x00FF; - IRQLatch|=V<<8; - break; - case 0x9006: IRQLatch&=0xFF00;IRQLatch|=V; - break; - case 0xB000:VROM_BANK1(0x0000,V);break; - case 0xB001:VROM_BANK1(0x0400,V);break; - case 0xB002:VROM_BANK1(0x0800,V);break; - case 0xB003:VROM_BANK1(0x0C00,V);break; - case 0xB004:VROM_BANK1(0x1000,V);break; - case 0xB005:VROM_BANK1(0x1400,V);break; - case 0xB006:VROM_BANK1(0x1800,V);break; - case 0xB007:VROM_BANK1(0x1C00,V);break; - case 0xa000:ROM_BANK8(0xA000,V);break; - case 0xC000:ROM_BANK8(0xC000,V);break; - } - //MIRROR_SET2(1); -} - -void Mapper65_init(void) -{ - MapIRQHook=IREMIRQHook; - SetWriteHandler(0x8000,0xffff,Mapper65_write); -} diff --git a/mappers/67.c b/mappers/67.c deleted file mode 100644 index 9d560f91..00000000 --- a/mappers/67.c +++ /dev/null @@ -1,78 +0,0 @@ -/* 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" - - -#define suntoggle mapbyte1[0] - -static DECLFW(Mapper67_write) -{ - A&=0xF800; - if((A&0x800) && A<=0xb800) - { - VROM_BANK2((A-0x8800)>>1,V); - } - else switch(A) - { - case 0xc800: - case 0xc000:if(!suntoggle) - { - IRQCount&=0xFF; - IRQCount|=V<<8; - } - else - { - IRQCount&=0xFF00; - IRQCount|=V; - } - suntoggle^=1; - break; - case 0xd800:suntoggle=0;IRQa=V&0x10;X6502_IRQEnd(FCEU_IQEXT);break; - - case 0xe800:switch(V&3) - { - case 0:MIRROR_SET2(1);break; - case 1:MIRROR_SET2(0);break; - case 2:onemir(0);break; - case 3:onemir(1);break; - } - break; - case 0xf800:ROM_BANK16(0x8000,V);break; - } -} -static void FP_FASTAPASS(1) SunIRQHook(int a) -{ - if(IRQa) - { - IRQCount-=a; - if(IRQCount<=0) - { - X6502_IRQBegin(FCEU_IQEXT); - IRQa=0; - IRQCount=0xFFFF; - } - } -} -void Mapper67_init(void) -{ -SetWriteHandler(0x8000,0xffff,Mapper67_write); -MapIRQHook=SunIRQHook; -} diff --git a/mappers/68.c b/mappers/68.c deleted file mode 100644 index 69eaefc5..00000000 --- a/mappers/68.c +++ /dev/null @@ -1,105 +0,0 @@ -/* 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 void Fixerit(void) -{ - switch(mapbyte2[0]&3) - { - case 0:vnapage[0]=vnapage[2]=CHRptr[0]+(((mapbyte1[0]|128)&CHRmask1[0])<<10); - vnapage[1]=vnapage[3]=CHRptr[0]+(((mapbyte1[1]|128)&CHRmask1[0])<<10); - break; - case 1:vnapage[0]=vnapage[1]=CHRptr[0]+(((mapbyte1[0]|128)&CHRmask1[0])<<10); - vnapage[2]=vnapage[3]=CHRptr[0]+(((mapbyte1[1]|128)&CHRmask1[0])<<10); - break; - case 2:vnapage[0]=vnapage[1]=vnapage[2]=vnapage[3]=CHRptr[0]+(((mapbyte1[0]|128)&CHRmask1[0])<<10); - break; - case 3:vnapage[0]=vnapage[1]=vnapage[2]=vnapage[3]=CHRptr[0]+(((mapbyte1[1]|128)&CHRmask1[0])<<10); - break; - } -} - -DECLFW(Mapper68_write) -{ -// FCEU_printf("%04x,%04x\n",A,V); - A&=0xF000; - - if(A>=0x8000 && A<=0xB000) - { - VROM_BANK2((A-0x8000)>>1,V); - } - else switch(A) - { - case 0xc000:mapbyte1[0]=V; - if(VROM_size && mapbyte2[0]&0x10) - Fixerit(); - break; - - case 0xd000:mapbyte1[1]=V; - if(VROM_size && mapbyte2[0]&0x10) - Fixerit(); - break; - - case 0xe000: mapbyte2[0]=V; - if(!(V&0x10)) - { - switch(V&3) - { - case 0:MIRROR_SET2(1);break; - case 1:MIRROR_SET2(0);break; - case 2:onemir(0);break; - case 3:onemir(1);break; - } - } - else if(VROM_size) - { - Fixerit(); - PPUNTARAM=0; - } - break; - case 0xf000: ROM_BANK16(0x8000,V);break; - } -} - -static void Mapper68_StateRestore(int version) -{ - if(!(mapbyte2[0]&0x10)) - { - switch(mapbyte2[0]&3) - { - case 0:MIRROR_SET(0);break; - case 1:MIRROR_SET(1);break; - case 2:onemir(0);break; - case 3:onemir(1);break; - } - } - else if(VROM_size) - { - Fixerit(); - PPUNTARAM=0; - } -} - -void Mapper68_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper68_write); - MapStateRestore=Mapper68_StateRestore; -} diff --git a/mappers/69.c b/mappers/69.c deleted file mode 100644 index 057a5129..00000000 --- a/mappers/69.c +++ /dev/null @@ -1,252 +0,0 @@ -/* 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 void AYSound(int Count); -static void AYSoundHQ(void); -static void DoAYSQ(int x); -static void DoAYSQHQ(int x); - -#define sunselect mapbyte1[0] -#define sungah mapbyte1[1] -static uint8 sunindex; - -static DECLFW(SUN5BWRAM) -{ - if((sungah&0xC0)==0xC0) - (WRAM-0x6000)[A]=V; -} - -static DECLFR(SUN5AWRAM) -{ - if((sungah&0xC0)==0x40) - return X.DB; - return CartBR(A); -} - -static DECLFW(Mapper69_SWL) -{ - sunindex=V%14; -} - -static DECLFW(Mapper69_SWH) -{ - int x; - GameExpSound.Fill=AYSound; - GameExpSound.HiFill=AYSoundHQ; - if(FSettings.SndRate); - switch(sunindex) - { - case 0: - case 1: - case 8:if(FSettings.soundq>=1) DoAYSQHQ(0); else DoAYSQ(0);break; - case 2: - case 3: - case 9:if(FSettings.soundq>=1) DoAYSQHQ(1); else DoAYSQ(1);break; - case 4: - case 5: - case 10:if(FSettings.soundq>=1) DoAYSQHQ(2); else DoAYSQ(2);break; - case 7: - for(x=0;x<2;x++) - if(FSettings.soundq>=1) DoAYSQHQ(x); else DoAYSQ(x); - break; - } - MapperExRAM[sunindex]=V; -} - -static DECLFW(Mapper69_write) -{ - switch(A&0xE000) - { - case 0x8000:sunselect=V;break; - case 0xa000: - sunselect&=0xF; - if(sunselect<=7) - VROM_BANK1(sunselect<<10,V); - else - switch(sunselect&0x0f) - { - case 8: - sungah=V; - if(V&0x40) - { - if(V&0x80) // Select WRAM - setprg8r(0x10,0x6000,0); - } - else - setprg8(0x6000,V); - break; - case 9:ROM_BANK8(0x8000,V);break; - case 0xa:ROM_BANK8(0xa000,V);break; - case 0xb:ROM_BANK8(0xc000,V);break; - case 0xc: - switch(V&3) - { - case 0:MIRROR_SET2(1);break; - case 1:MIRROR_SET2(0);break; - case 2:onemir(0);break; - case 3:onemir(1);break; - } - break; - case 0xd:IRQa=V;X6502_IRQEnd(FCEU_IQEXT);break; - case 0xe:IRQCount&=0xFF00;IRQCount|=V;X6502_IRQEnd(FCEU_IQEXT);break; - case 0xf:IRQCount&=0x00FF;IRQCount|=V<<8;X6502_IRQEnd(FCEU_IQEXT);break; - } - break; - } -} - -static int32 vcount[3]; -static int32 dcount[3]; -static int CAYBC[3]; - -static void DoAYSQ(int x) -{ - int32 freq=((MapperExRAM[x<<1]|((MapperExRAM[(x<<1)+1]&15)<<8))+1)<<(4+17); - int32 amp=(MapperExRAM[0x8+x]&15)<<2; - int32 start,end; - int V; - - amp+=amp>>1; - - start=CAYBC[x]; - end=(SOUNDTS<<16)/soundtsinc; - if(end<=start) return; - CAYBC[x]=end; - - if(amp) - for(V=start;V>4]+=amp; - vcount[x]-=nesincsize; - while(vcount[x]<=0) - { - dcount[x]^=1; - vcount[x]+=freq; - } - } -} - -static void DoAYSQHQ(int x) -{ - int32 V; - int32 freq=((MapperExRAM[x<<1]|((MapperExRAM[(x<<1)+1]&15)<<8))+1)<<4; - int32 amp=(MapperExRAM[0x8+x]&15)<<6; - - amp+=amp>>1; - - if(!(MapperExRAM[0x7]&(1<>3)&2);break; - } -} - -void Mapper71_init(void) -{ -SetWriteHandler(0x4020,0xffff,Mapper71_write); -} - diff --git a/mappers/72.c b/mappers/72.c deleted file mode 100644 index 480a035a..00000000 --- a/mappers/72.c +++ /dev/null @@ -1,37 +0,0 @@ -/* 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" - - -DECLFW(Mapper72_write) -{ - mapbyte1[0]=V; - if(V&0x80) - ROM_BANK16(0x8000,V&0xF); - if(V&0x40) - VROM_BANK8(V&0xF); -} - -void Mapper72_init(void) -{ - SetWriteHandler(0x6000,0xffff,Mapper72_write); -} - diff --git a/mappers/73.c b/mappers/73.c deleted file mode 100644 index b49fa249..00000000 --- a/mappers/73.c +++ /dev/null @@ -1,60 +0,0 @@ -/* 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 DECLFW(Mapper73_write) -{ - //if(A>=0xd000 && A<=0xdfff) - X6502_IRQEnd(FCEU_IQEXT); /* How are IRQs acknowledged on this chip? */ - switch(A&0xF000) - { - //default: printf("$%04x:$%02x\n",A,V);break; - case 0x8000:IRQCount&=0xFFF0;IRQCount|=(V&0xF);break; - case 0x9000:IRQCount&=0xFF0F;IRQCount|=(V&0xF)<<4;break; - case 0xa000:IRQCount&=0xF0FF;IRQCount|=(V&0xF)<<8;break; - case 0xb000:IRQCount&=0x0FFF;IRQCount|=(V&0xF)<<12;break; - case 0xc000:IRQa=V&2;break; - case 0xf000:ROM_BANK16(0x8000,V);break; - } -} - -static void FP_FASTAPASS(1) Mapper73IRQHook(int a) -{ - if(IRQa) - { - IRQCount+=a; - if(IRQCount>=0xFFFF) - { - IRQCount&=0xFFFF; - IRQa=0; - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -void Mapper73_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper73_write); - MapIRQHook=Mapper73IRQHook; -} - diff --git a/mappers/75.c b/mappers/75.c deleted file mode 100644 index f2b00bd6..00000000 --- a/mappers/75.c +++ /dev/null @@ -1,47 +0,0 @@ -/* 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" - - -#define map75sel mapbyte1[0] -#define map75ar mapbyte2 - -DECLFW(Mapper75_write) -{ -switch(A&0xF000) - { - case 0x8000:ROM_BANK8(0x8000,V);break; - case 0x9000: - VROM_BANK4(0x0000,map75ar[0]|((V&2)<<3)); - VROM_BANK4(0x1000,map75ar[1]|((V&4)<<2)); - map75sel=V;MIRROR_SET(V&1);break; - case 0xa000:ROM_BANK8(0xa000,V);break; - case 0xc000:ROM_BANK8(0xc000,V);break; - case 0xe000:V&=0xF;map75ar[0]=V;V|=(map75sel&2)<<3;VROM_BANK4(0x0000,V);break; - case 0xf000:V&=0xF;map75ar[1]=V;V|=(map75sel&4)<<2;VROM_BANK4(0x1000,V);break; - } -} - -void Mapper75_init(void) -{ -SetWriteHandler(0x8000,0xffff,Mapper75_write); -} - diff --git a/mappers/76.c b/mappers/76.c deleted file mode 100644 index a59ef1e2..00000000 --- a/mappers/76.c +++ /dev/null @@ -1,54 +0,0 @@ -/* 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 MMC3_cmd; - -static DECLFW(Mapper76_write) -{ - switch(A&0xE001){ - case 0x8000: - MMC3_cmd = V; - break; - case 0x8001: - switch(MMC3_cmd&0x07){ - case 2: VROM_BANK2(0x000,V);break; - case 3: VROM_BANK2(0x800,V);break; - case 4: VROM_BANK2(0x1000,V);break; - case 5: VROM_BANK2(0x1800,V);break; - case 6: - if(MMC3_cmd&0x40) ROM_BANK8(0xC000,V); - else ROM_BANK8(0x8000,V); - break; - case 7: ROM_BANK8(0xA000,V); - break; - } - break; - case 0xA000: - MIRROR_SET(V&1); - break; - } -} - -void Mapper76_init(void) -{ -SetWriteHandler(0x8000,0xffff,Mapper76_write); -} - diff --git a/mappers/77.c b/mappers/77.c deleted file mode 100644 index 06f15cc0..00000000 --- a/mappers/77.c +++ /dev/null @@ -1,54 +0,0 @@ -/* 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" - -/* Original code provided by LULU */ - -static DECLFW(Mapper77_write) -{ - mapbyte1[0]=V; - ROM_BANK32(V&0x7); - VROM_BANK2(0x0000, (V&0xf0)>>4); -} - -static void Mapper77_StateRestore(int version) -{ - int x; - - if(version>=7200) - { - ROM_BANK32(mapbyte1[0]&0x7); - VROM_BANK2(0x0000, (mapbyte1[0]&0xf0)>>4); - } - for(x=2;x<8;x++) - VRAM_BANK1(x*0x400,x); -} - -void Mapper77_init(void) -{ - int x; - - ROM_BANK32(0); - for(x=2;x<8;x++) - VRAM_BANK1(x*0x400,x); - SetWriteHandler(0x6000,0xffff,Mapper77_write); - MapStateRestore=Mapper77_StateRestore; -} diff --git a/mappers/79.c b/mappers/79.c deleted file mode 100644 index 9148eae6..00000000 --- a/mappers/79.c +++ /dev/null @@ -1,40 +0,0 @@ -/* 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" - - - -DECLFW(Mapper79_write) -{ - if(A<0x8000 && ((A^0x4100)==0)) - { - ROM_BANK32((V>>3)&1); - } - VROM_BANK8(V); -} - -void Mapper79_init(void) -{ - ROM_BANK32(~0); - SetWriteHandler(0x8000,0xffff,Mapper79_write); - SetWriteHandler(0x4020,0x5fff,Mapper79_write); -} - diff --git a/mappers/8.c b/mappers/8.c deleted file mode 100644 index 53c91a28..00000000 --- a/mappers/8.c +++ /dev/null @@ -1,34 +0,0 @@ -/* 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 DECLFW(Mapper8_write) -{ - ROM_BANK16(0x8000,V>>3); - VROM_BANK8(V&7); -} - -void Mapper8_init(void) -{ - ROM_BANK32(0); - SetWriteHandler(0x8000,0xFFFF,Mapper8_write); -} - diff --git a/mappers/80.c b/mappers/80.c deleted file mode 100644 index 1e7982e8..00000000 --- a/mappers/80.c +++ /dev/null @@ -1,100 +0,0 @@ -/* 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 uint32 lastA; -static int isfu; -static uint8 CCache[8]; - -static void FP_FASTAPASS(1) Fudou_PPU(uint32 A) -{ - static int last=-1; - static uint8 z; - - if(A>=0x2000) return; - - A>>=10; - lastA=A; - - z=CCache[A]; - if(z!=last) - { - onemir(z); - last=z; - } -} - -static void mira() -{ - if(isfu) - { - int x; - CCache[0]=CCache[1]=mapbyte2[0]>>7; - CCache[2]=CCache[3]=mapbyte2[1]>>7; - - for(x=0;x<4;x++) - CCache[4+x]=mapbyte2[2+x]>>7; - - onemir(CCache[lastA]); - } - else - MIRROR_SET2(mapbyte1[0]&1); -} - -static DECLFW(Mapper80_write) -{ - switch(A) - { - case 0x7ef0: mapbyte2[0]=V;VROM_BANK2(0x0000,(V>>1)&0x3F);mira();break; - case 0x7ef1: mapbyte2[1]=V;VROM_BANK2(0x0800,(V>>1)&0x3f);mira();break; - - case 0x7ef2: mapbyte2[2]=V;VROM_BANK1(0x1000,V);mira();break; - case 0x7ef3: mapbyte2[3]=V;VROM_BANK1(0x1400,V);mira();break; - case 0x7ef4: mapbyte2[4]=V;VROM_BANK1(0x1800,V);mira();break; - case 0x7ef5: mapbyte2[5]=V;VROM_BANK1(0x1c00,V);mira();break; - case 0x7ef6: mapbyte1[0]=V;mira();break; - case 0x7efa: - case 0x7efb: ROM_BANK8(0x8000,V);break; - case 0x7efd: - case 0x7efc: ROM_BANK8(0xA000,V);break; - case 0x7efe: - case 0x7eff: ROM_BANK8(0xC000,V);break; - } -} - -static void booga(int version) -{ - mira(); -} - -void Mapper80_init(void) -{ - SetWriteHandler(0x4020,0x7fff,Mapper80_write); - MapStateRestore=booga; - isfu=0; -} - -void Mapper207_init(void) -{ - Mapper80_init(); - isfu=1; - PPU_hook=Fudou_PPU; -} diff --git a/mappers/82.c b/mappers/82.c deleted file mode 100644 index b4288b1f..00000000 --- a/mappers/82.c +++ /dev/null @@ -1,62 +0,0 @@ -/* 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" - -#define ctrl mapbyte1[6] - -static void DoCHR(void) -{ - int x; - - for(x=0;x<2;x++) - VROM_BANK2((x<<11)|((ctrl&2)<<11),mapbyte1[x]>>1); - for(x=0;x<4;x++) - VROM_BANK1((x<<10) | (((ctrl&2)^2)<<11),mapbyte1[2+x]); -} - -static DECLFW(Mapper82_write) -{ - if(A<=0x7EF5) - { - mapbyte1[A&7]=V; - DoCHR(); - } - else - switch(A) - { - case 0x7ef6:ctrl=V&3; - MIRROR_SET2(V&1); - DoCHR(); - break; - case 0x7efa:V>>=2;mapbyte2[0]=V;ROM_BANK8(0x8000,V);break; - case 0x7efb:V>>=2;mapbyte2[1]=V;ROM_BANK8(0xa000,V);break; - case 0x7efc:V>>=2;mapbyte2[2]=V;ROM_BANK8(0xc000,V);break; - } -} - -void Mapper82_init(void) -{ - ROM_BANK8(0xE000,~0); - - /* external WRAM might end at $73FF */ - SetWriteHandler(0x7ef0,0x7efc,Mapper82_write); -} - diff --git a/mappers/83.c b/mappers/83.c deleted file mode 100644 index 9a3bcd7b..00000000 --- a/mappers/83.c +++ /dev/null @@ -1,131 +0,0 @@ -/* 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" - - -/*void Mapper83_init(void) -{ - -} -*/ -static void FP_FASTAPASS(1) m83IRQHook(int a) -{ - if(IRQa) - { - IRQCount-=a; - if(IRQCount<0) - { - X6502_IRQBegin(FCEU_IQEXT); - IRQa=0; - IRQCount=0xFFFF; - } - } -} - -static DECLFW(wrlow) -{ - mapbyte4[A&3]=V; -} - -static DECLFR(rdlow) -{ - return mapbyte4[A&3]; -} - -static void m83prg(void) -{ - ROM_BANK16(0x8000,(mapbyte1[0]&0x3F)); - ROM_BANK16(0xC000,(mapbyte1[0]&0x30)|0xF); -} - -static void m83chr(void) -{ -// if(0) -// { -// VROM_BANK2(0x0000,mapbyte2[0]); -// VROM_BANK2(0x0800,mapbyte2[1]); -// VROM_BANK2(0x1000,mapbyte2[6]); -// VROM_BANK2(0x1800,mapbyte2[7]); -// } -// else -// { - int x; - for(x=0;x<8;x++) - VROM_BANK1(x*0x400,mapbyte2[x]|((mapbyte1[0]&0x30)<<4)); -// } -} - -static DECLFW(Mapper83_write) -{ - //printf("$%04x:$%02x\n",A,V); - switch(A) - { - case 0x8000: - case 0xB000: - case 0xB0FF: - case 0xB1FF: - { - mapbyte1[0]=V; - m83prg(); - m83chr(); - } - break; - case 0x8100: - mapbyte3[0]=V&0x80; - switch(V&0x3) - { - case 0x00:MIRROR_SET2(1);break; - case 0x01:MIRROR_SET2(0);break; - case 0x02:onemir(0);break; - case 0x03:onemir(1);break; - } - break; - case 0x8200:IRQCount&=0xFF00;IRQCount|=V;X6502_IRQEnd(FCEU_IQEXT);break; - case 0x8201:IRQa=mapbyte3[0];IRQCount&=0xFF;IRQCount|=V<<8;break; - case 0x8300:ROM_BANK8(0x8000,V);break; - case 0x8301:ROM_BANK8(0xA000,V);break; - case 0x8302:ROM_BANK8(0xC000,V);break; - case 0x8310:mapbyte2[0]=V;m83chr();break; - case 0x8311:mapbyte2[1]=V;m83chr();break; - case 0x8312:mapbyte2[2]=V;m83chr();break; - case 0x8313:mapbyte2[3]=V;m83chr();break; - case 0x8314:mapbyte2[4]=V;m83chr();break; - case 0x8315:mapbyte2[5]=V;m83chr();break; - case 0x8316:mapbyte2[6]=V;m83chr();break; - case 0x8317:mapbyte2[7]=V;m83chr();break; - case 0x8318:mapbyte1[1]=V;m83prg();break; - } -// printf("$%04x:$%02x, $%04x\n",A,V,X.PC.W); - -} - -void Mapper83_init(void) -{ - ROM_BANK8(0xc000,0x1e); - ROM_BANK8(0xe000,0x1f); - - MapIRQHook=m83IRQHook; - - SetReadHandler(0x5100,0x5103,rdlow); - SetWriteHandler(0x5100,0x5103,wrlow); - SetWriteHandler(0x8000,0xffff,Mapper83_write); - mapbyte1[1]=0xF; -} diff --git a/mappers/85.c b/mappers/85.c deleted file mode 100644 index 3283182d..00000000 --- a/mappers/85.c +++ /dev/null @@ -1,195 +0,0 @@ -/* 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" - -#define vrctemp mapbyte1[0] -static uint8 indox; - -#include "emu2413.h" - -static int acount=0; - -static OPLL *VRC7Sound=NULL; -static int dwave=0; - -void DoVRC7Sound(void) -{ - int32 z,a; - - if(FSettings.soundq>=1) return; - z=((SOUNDTS<<16)/soundtsinc)>>4; - a=z-dwave; - - moocow(VRC7Sound, &Wave[dwave], a, 1); - - dwave+=a; -} - -void UpdateOPLNEO(int32 *Wave, int Count) -{ - moocow(VRC7Sound, Wave, Count, 4); -} - -void UpdateOPL(int Count) -{ - int32 z,a; - - z=((SOUNDTS<<16)/soundtsinc)>>4; - a=z-dwave; - - if(VRC7Sound && a) - moocow(VRC7Sound, &Wave[dwave], a, 1); - - dwave=0; -} - -static INLINE void DaMirror(int V) -{ - int salpo[4]={MI_V,MI_H,MI_0,MI_1}; - setmirror(salpo[V&3]); -} - -DECLFW(Mapper85_write) -{ - A|=(A&8)<<1; - - if(A>=0xa000 && A<=0xDFFF) - { - // printf("$%04x, $%04x\n",X.PC,A); - A&=0xF010; - { - int x=((A>>4)&1)|((A-0xA000)>>11); - mapbyte3[x]=V; - setchr1(x<<10,V); - } - } - else if(A==0x9030) - { - if(FSettings.SndRate) - { - OPLL_writeReg(VRC7Sound, indox, V); - GameExpSound.Fill=UpdateOPL; - GameExpSound.NeoFill=UpdateOPLNEO; - } - } - else switch(A&0xF010) - { - case 0x8000:mapbyte2[0]=V;setprg8(0x8000,V);break; - case 0x8010:mapbyte2[1]=V;setprg8(0xa000,V);break; - case 0x9000:mapbyte2[2]=V;setprg8(0xc000,V);break; - case 0x9010:indox=V;break; - case 0xe000:mapbyte2[3]=V;DaMirror(V);break; - case 0xE010:IRQLatch=V; - X6502_IRQEnd(FCEU_IQEXT); - break; - case 0xF000:IRQa=V&2; - vrctemp=V&1; - if(V&2) {IRQCount=IRQLatch;} - acount=0; - X6502_IRQEnd(FCEU_IQEXT); - break; - case 0xf010:if(vrctemp) IRQa=1; - else IRQa=0; - X6502_IRQEnd(FCEU_IQEXT); - break; - } -} - -static void FP_FASTAPASS(1) KonamiIRQHook(int a) -{ - #define ACBOO 341 -// #define ACBOO ((227*2)+1) - if(IRQa) - { - acount+=a*3; - - if(acount>=ACBOO) - { - doagainbub:acount-=ACBOO; - IRQCount++; - if(IRQCount&0x100) {X6502_IRQBegin(FCEU_IQEXT);IRQCount=IRQLatch;} - if(acount>=ACBOO) goto doagainbub; - } - } -} - -void Mapper85_StateRestore(int version) -{ - int x; - - if(version<7200) - { - for(x=0;x<8;x++) - mapbyte3[x]=CHRBankList[x]; - for(x=0;x<3;x++) - mapbyte2[x]=PRGBankList[x]; - mapbyte2[3]=(Mirroring<0x10)?Mirroring:Mirroring-0xE; - } - - for(x=0;x<8;x++) - setchr1(x*0x400,mapbyte3[x]); - for(x=0;x<3;x++) - setprg8(0x8000+x*8192,mapbyte2[x]); - DaMirror(mapbyte2[3]); - //LoadOPL(); -} - -static void M85SC(void) -{ - if(VRC7Sound) - OPLL_set_rate(VRC7Sound, FSettings.SndRate); -} - -static void M85SKill(void) -{ - if(VRC7Sound) - OPLL_delete(VRC7Sound); - VRC7Sound=NULL; -} - -static void VRC7SI(void) -{ - GameExpSound.RChange=M85SC; - GameExpSound.Kill=M85SKill; - - VRC7Sound=OPLL_new(3579545, FSettings.SndRate?FSettings.SndRate:44100); - OPLL_reset(VRC7Sound); - OPLL_reset(VRC7Sound); -} - -void NSFVRC7_Init(void) -{ - SetWriteHandler(0x9010,0x901F,Mapper85_write); - SetWriteHandler(0x9030,0x903F,Mapper85_write); - VRC7SI(); -} - -void Mapper85_init(void) -{ - MapIRQHook=KonamiIRQHook; - SetWriteHandler(0x8000,0xffff,Mapper85_write); - GameStateRestore=Mapper85_StateRestore; - if(!VROM_size) - SetupCartCHRMapping(0, CHRRAM, 8192, 1); - //AddExState(VRC7Instrument, 16, 0, "VC7I"); - //AddExState(VRC7Chan, sizeof(VRC7Chan), 0, "V7CH"); - VRC7SI(); -} diff --git a/mappers/86.c b/mappers/86.c deleted file mode 100644 index 8404985d..00000000 --- a/mappers/86.c +++ /dev/null @@ -1,38 +0,0 @@ -/* 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" - -DECLFW(Mapper86_write) -{ - if(A>=0x6000 && A<=0x6fFF) - { - VROM_BANK8((V&3)|((V>>4)&4)); - ROM_BANK32((V>>4)&3); - } - //else - //if(A!=0x6000) - // printf("$%04x:$%02x\n",A,V); -} -void Mapper86_init(void) -{ - SetWriteHandler(0x6000,0x6fff,Mapper86_write); - SetWriteHandler(0x4020,0xffff,Mapper86_write); -} diff --git a/mappers/89.c b/mappers/89.c deleted file mode 100644 index a3a6f09f..00000000 --- a/mappers/89.c +++ /dev/null @@ -1,34 +0,0 @@ -/* 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" - -DECLFW(Mapper89_write) -{ - VROM_BANK8((V&7)|((V>>4)&8)); - ROM_BANK16(0x8000,(V>>4)&7); - onemir((V>>3)&1); -} - -void Mapper89_init(void) -{ - Mirroring=0; - SetWriteHandler(0x8000,0xffff,Mapper89_write); -} diff --git a/mappers/91.c b/mappers/91.c deleted file mode 100644 index 8858103a..00000000 --- a/mappers/91.c +++ /dev/null @@ -1,59 +0,0 @@ -/* 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 DECLFW(Mapper91_write) -{ -//if(A>=0x7001) -//printf("$%04x:$%02x, %d\n",A,V,scanline); - A&=0xF007; - - if(A>=0x6000 && A<=0x6003) VROM_BANK2((A&3)*2048,V); - else switch(A&0xF003) - { - case 0x7000: - case 0x7001:ROM_BANK8(0x8000+(A&1)*8192,V);break; - case 0x7002:IRQa=IRQCount=0;X6502_IRQEnd(FCEU_IQEXT);break; - case 0x7003:IRQa=1;X6502_IRQEnd(FCEU_IQEXT);break; -// default: printf("Iyee: $%04x:$%02x\n",A,V);break; - } - //if(A>=0x7000) - // printf("$%04x:$%02x, %d\n",A,V,scanline); -} - -static void Mapper91_hb(void) -{ - if(IRQCount<8 && IRQa) - { - IRQCount++; - if(IRQCount>=8) - { - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -void Mapper91_init(void) -{ - SetWriteHandler(0x4020,0xFFFF,Mapper91_write); - GameHBIRQHook=Mapper91_hb; -} - diff --git a/mappers/92.c b/mappers/92.c deleted file mode 100644 index e2ad3749..00000000 --- a/mappers/92.c +++ /dev/null @@ -1,45 +0,0 @@ -/* 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" - -/* Original code provided by LULU */ - -static DECLFW(Mapper92_write) -{ - uint8 reg=(A&0xF0)>>4; - uint8 bank=A&0xF; - - if(A>=0x9000) - { - if(reg==0xD) ROM_BANK16(0xc000,bank); - else if(reg==0xE) VROM_BANK8(bank); - } - else - { - if(reg==0xB) ROM_BANK16(0xc000,bank); - else if(reg==0x7) VROM_BANK8(bank); - } -} - -void Mapper92_init(void) -{ - SetWriteHandler(0x8000,0xFFFF,Mapper92_write); -} diff --git a/mappers/97.c b/mappers/97.c deleted file mode 100644 index 2990c0e7..00000000 --- a/mappers/97.c +++ /dev/null @@ -1,42 +0,0 @@ -/* 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" - - - -DECLFW(Mapper97_write) -{ -ROM_BANK16(0xC000,V&15); -switch(V>>6) - { - case 0:break; - case 1:MIRROR_SET2(0);break; - case 2:MIRROR_SET2(1);break; - case 3:break; - } -} - -void Mapper97_init(void) -{ - ROM_BANK16(0x8000,~0); - SetWriteHandler(0x8000,0xffff,Mapper97_write); -} - diff --git a/mappers/99.c b/mappers/99.c deleted file mode 100644 index 7a55536b..00000000 --- a/mappers/99.c +++ /dev/null @@ -1,37 +0,0 @@ -/* 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 writefunc oldmorko; - -static DECLFW(morko) -{ - VROM_BANK8((V>>2)&1); - oldmorko(A,V); - setprg8(0x8000,V&0x4); /* Special for VS Gumshoe */ -} - -void Mapper99_init(void) -{ - ROM_BANK32(0); - oldmorko=GetWriteHandler(0x4016); - SetWriteHandler(0x4016,0x4016,morko); -} diff --git a/mappers/Makefile.am.inc b/mappers/Makefile.am.inc deleted file mode 100644 index 631d532d..00000000 --- a/mappers/Makefile.am.inc +++ /dev/null @@ -1 +0,0 @@ -fceu_SOURCES += mappers/113.c mappers/15.c mappers/151.c mappers/16.c mappers/17.c mappers/18.c mappers/180.c mappers/183.c mappers/184.c mappers/193.c mappers/200.c mappers/201.c mappers/202.c mappers/203.c mappers/204.c mappers/21.c mappers/212.c mappers/213.c mappers/214.c mappers/215.c mappers/217.c mappers/22.c mappers/225.c mappers/226.c mappers/227.c mappers/228.c mappers/229.c mappers/23.c mappers/230.c mappers/231.c mappers/232.c mappers/234.c mappers/240.c mappers/241.c mappers/242.c mappers/244.c mappers/246.c mappers/24and26.c mappers/25.c mappers/255.c mappers/27.c mappers/32.c mappers/33.c mappers/40.c mappers/41.c mappers/42.c mappers/43.c mappers/46.c mappers/50.c mappers/51.c mappers/59.c mappers/6.c mappers/60.c mappers/61.c mappers/62.c mappers/65.c mappers/67.c mappers/68.c mappers/69.c mappers/71.c mappers/72.c mappers/73.c mappers/75.c mappers/76.c mappers/77.c mappers/79.c mappers/8.c mappers/80.c mappers/82.c mappers/83.c mappers/85.c mappers/86.c mappers/89.c mappers/91.c mappers/92.c mappers/97.c mappers/99.c mappers/emu2413.c mappers/mmc2and4.c mappers/simple.c diff --git a/mappers/emu2413.c b/mappers/emu2413.c deleted file mode 100644 index 49aa3396..00000000 --- a/mappers/emu2413.c +++ /dev/null @@ -1,1300 +0,0 @@ -/*********************************************************************************** - - emu2413.c -- YM2413 emulator written by Mitsutaka Okazaki 2001 - - 2001 01-08 : Version 0.10 -- 1st version. - 2001 01-15 : Version 0.20 -- semi-public version. - 2001 01-16 : Version 0.30 -- 1st public version. - 2001 01-17 : Version 0.31 -- Fixed bassdrum problem. - : Version 0.32 -- LPF implemented. - 2001 01-18 : Version 0.33 -- Fixed the drum problem, refine the mix-down method. - -- Fixed the LFO bug. - 2001 01-24 : Version 0.35 -- Fixed the drum problem, - support undocumented EG behavior. - 2001 02-02 : Version 0.38 -- Improved the performance. - Fixed the hi-hat and cymbal model. - Fixed the default percussive datas. - Noise reduction. - Fixed the feedback problem. - 2001 03-03 : Version 0.39 -- Fixed some drum bugs. - Improved the performance. - 2001 03-04 : Version 0.40 -- Improved the feedback. - Change the default table size. - Clock and Rate can be changed during play. - 2001 06-24 : Version 0.50 -- Improved the hi-hat and the cymbal tone. - Added VRC7 patch (OPLL_reset_patch is changed). - Fixed OPLL_reset() bug. - Added OPLL_setMask, OPLL_getMask and OPLL_toggleMask. - Added OPLL_writeIO. - 2001 09-28 : Version 0.51 -- Removed the noise table. - 2002 01-28 : Version 0.52 -- Added Stereo mode. - 2002 02-07 : Version 0.53 -- Fixed some drum bugs. - 2002 02-20 : Version 0.54 -- Added the best quality mode. - 2002 03-02 : Version 0.55 -- Removed OPLL_init & OPLL_close. - 2002 05-30 : Version 0.60 -- Fixed HH&CYM generator and all voice datas. - - 2004 01-24 : Modified by xodnizel to remove code not needed for the VRC7, among other things. - - References: - fmopl.c -- 1999,2000 written by Tatsuyuki Satoh (MAME development). - fmopl.c(fixed) -- (C) 2002 Jarek Burczynski. - s_opl.c -- 2001 written by Mamiya (NEZplug development). - fmgen.cpp -- 1999,2000 written by cisc. - fmpac.ill -- 2000 created by NARUTO. - MSX-Datapack - YMU757 data sheet - YM2143 data sheet - -**************************************************************************************/ -#include -#include -#include -#include -#include "emu2413.h" - -static const unsigned char default_inst[15][8] = { - #include "vrc7tone.h" -}; - -/* Size of Sintable ( 8 -- 18 can be used. 9 recommended.)*/ -#define PG_BITS 9 -#define PG_WIDTH (1<>(b)) - -/* Leave the lower b bit(s). */ -#define LOWBITS(c,b) ((c)&((1<<(b))-1)) - -/* Expand x which is s bits to d bits. */ -#define EXPAND_BITS(x,s,d) ((x)<<((d)-(s))) - -/* Expand x which is s bits to d bits and fill expanded bits '1' */ -#define EXPAND_BITS_X(x,s,d) (((x)<<((d)-(s)))|((1<<((d)-(s)))-1)) - -/* Adjust envelope speed which depends on sampling rate. */ -#define rate_adjust(x) (rate==49716?x:(e_uint32)((double)(x)*clk/72/rate + 0.5)) /* added 0.5 to round the value*/ - -#define MOD(o,x) (&(o)->slot[(x)<<1]) -#define CAR(o,x) (&(o)->slot[((x)<<1)|1]) - -#define BIT(s,b) (((s)>>(b))&1) - -/* Input clock */ -static e_uint32 clk = 844451141; -/* Sampling rate */ -static e_uint32 rate = 3354932; - -/* WaveTable for each envelope amp */ -static e_uint16 fullsintable[PG_WIDTH]; -static e_uint16 halfsintable[PG_WIDTH]; - -static e_uint16 *waveform[2] = { fullsintable, halfsintable }; - -/* LFO Table */ -static e_int32 pmtable[PM_PG_WIDTH]; -static e_int32 amtable[AM_PG_WIDTH]; - -/* Phase delta for LFO */ -static e_uint32 pm_dphase; -static e_uint32 am_dphase; - -/* dB to Liner table */ -static e_int16 DB2LIN_TABLE[(DB_MUTE + DB_MUTE) * 2]; - -/* Liner to Log curve conversion table (for Attack rate). */ -static e_uint16 AR_ADJUST_TABLE[1 << EG_BITS]; - -/* Definition of envelope mode */ -enum -{ SETTLE, ATTACK, DECAY, SUSHOLD, SUSTINE, RELEASE, FINISH }; - -/* Phase incr table for Attack */ -static e_uint32 dphaseARTable[16][16]; -/* Phase incr table for Decay and Release */ -static e_uint32 dphaseDRTable[16][16]; - -/* KSL + TL Table */ -static e_uint32 tllTable[16][8][1 << TL_BITS][4]; -static e_int32 rksTable[2][8][2]; - -/* Phase incr table for PG */ -static e_uint32 dphaseTable[512][8][16]; - -/*************************************************** - - Create tables - -****************************************************/ -INLINE static e_int32 -Min (e_int32 i, e_int32 j) -{ - if(i < j) - return i; - else - return j; -} - -/* Table for AR to LogCurve. */ -static void -makeAdjustTable (void) -{ - e_int32 i; - - AR_ADJUST_TABLE[0] = (1 << EG_BITS); - for (i = 1; i < 128; i++) - AR_ADJUST_TABLE[i] = (e_uint16) ((double) (1 << EG_BITS) - 1 - (1 << EG_BITS) * log (i) / log (128)); -} - - -/* Table for dB(0 -- (1<= DB_MUTE) DB2LIN_TABLE[i] = 0; - DB2LIN_TABLE[i + DB_MUTE + DB_MUTE] = (e_int16) (-DB2LIN_TABLE[i]); - } -} - -/* Liner(+0.0 - +1.0) to dB((1<> (20 - DP_BITS)); -} - -static void -makeTllTable (void) -{ -#define dB2(x) ((x)*2) - - static double kltable[16] = { - dB2 (0.000), dB2 (9.000), dB2 (12.000), dB2 (13.875), dB2 (15.000), dB2 (16.125), dB2 (16.875), dB2 (17.625), - dB2 (18.000), dB2 (18.750), dB2 (19.125), dB2 (19.500), dB2 (19.875), dB2 (20.250), dB2 (20.625), dB2 (21.000) - }; - - e_int32 tmp; - e_int32 fnum, block, TL, KL; - - for (fnum = 0; fnum < 16; fnum++) - for (block = 0; block < 8; block++) - for (TL = 0; TL < 64; TL++) - for (KL = 0; KL < 4; KL++) - { - if(KL == 0) - { - tllTable[fnum][block][TL][KL] = TL2EG (TL); - } - else - { - tmp = (e_int32) (kltable[fnum] - dB2 (3.000) * (7 - block)); - if(tmp <= 0) - tllTable[fnum][block][TL][KL] = TL2EG (TL); - else - tllTable[fnum][block][TL][KL] = (e_uint32) ((tmp >> (3 - KL)) / EG_STEP) + TL2EG (TL); - } - } -} - -#ifdef USE_SPEC_ENV_SPEED -static double attacktime[16][4] = { - {0, 0, 0, 0}, - {1730.15, 1400.60, 1153.43, 988.66}, - {865.08, 700.30, 576.72, 494.33}, - {432.54, 350.15, 288.36, 247.16}, - {216.27, 175.07, 144.18, 123.58}, - {108.13, 87.54, 72.09, 61.79}, - {54.07, 43.77, 36.04, 30.90}, - {27.03, 21.88, 18.02, 15.45}, - {13.52, 10.94, 9.01, 7.72}, - {6.76, 5.47, 4.51, 3.86}, - {3.38, 2.74, 2.25, 1.93}, - {1.69, 1.37, 1.13, 0.97}, - {0.84, 0.70, 0.60, 0.54}, - {0.50, 0.42, 0.34, 0.30}, - {0.28, 0.22, 0.18, 0.14}, - {0.00, 0.00, 0.00, 0.00} -}; - -static double decaytime[16][4] = { - {0, 0, 0, 0}, - {20926.60, 16807.20, 14006.00, 12028.60}, - {10463.30, 8403.58, 7002.98, 6014.32}, - {5231.64, 4201.79, 3501.49, 3007.16}, - {2615.82, 2100.89, 1750.75, 1503.58}, - {1307.91, 1050.45, 875.37, 751.79}, - {653.95, 525.22, 437.69, 375.90}, - {326.98, 262.61, 218.84, 187.95}, - {163.49, 131.31, 109.42, 93.97}, - {81.74, 65.65, 54.71, 46.99}, - {40.87, 32.83, 27.36, 23.49}, - {20.44, 16.41, 13.68, 11.75}, - {10.22, 8.21, 6.84, 5.87}, - {5.11, 4.10, 3.42, 2.94}, - {2.55, 2.05, 1.71, 1.47}, - {1.27, 1.27, 1.27, 1.27} -}; -#endif - -/* Rate Table for Attack */ -static void -makeDphaseARTable (void) -{ - e_int32 AR, Rks, RM, RL; -#ifdef USE_SPEC_ENV_SPEED - e_uint32 attacktable[16][4]; - - for (RM = 0; RM < 16; RM++) - for (RL = 0; RL < 4; RL++) - { - if(RM == 0) - attacktable[RM][RL] = 0; - else if(RM == 15) - attacktable[RM][RL] = EG_DP_WIDTH; - else - attacktable[RM][RL] = (e_uint32) ((double) (1 << EG_DP_BITS) / (attacktime[RM][RL] * 3579545 / 72000)); - - } -#endif - - for (AR = 0; AR < 16; AR++) - for (Rks = 0; Rks < 16; Rks++) - { - RM = AR + (Rks >> 2); - RL = Rks & 3; - if(RM > 15) - RM = 15; - switch (AR) - { - case 0: - dphaseARTable[AR][Rks] = 0; - break; - case 15: - dphaseARTable[AR][Rks] = 0;/*EG_DP_WIDTH;*/ - break; - default: -#ifdef USE_SPEC_ENV_SPEED - dphaseARTable[AR][Rks] = rate_adjust (attacktable[RM][RL]); -#else - dphaseARTable[AR][Rks] = rate_adjust ((3 * (RL + 4) << (RM + 1))); -#endif - break; - } - } -} - -/* Rate Table for Decay and Release */ -static void -makeDphaseDRTable (void) -{ - e_int32 DR, Rks, RM, RL; - -#ifdef USE_SPEC_ENV_SPEED - e_uint32 decaytable[16][4]; - - for (RM = 0; RM < 16; RM++) - for (RL = 0; RL < 4; RL++) - if(RM == 0) - decaytable[RM][RL] = 0; - else - decaytable[RM][RL] = (e_uint32) ((double) (1 << EG_DP_BITS) / (decaytime[RM][RL] * 3579545 / 72000)); -#endif - - for (DR = 0; DR < 16; DR++) - for (Rks = 0; Rks < 16; Rks++) - { - RM = DR + (Rks >> 2); - RL = Rks & 3; - if(RM > 15) - RM = 15; - switch (DR) - { - case 0: - dphaseDRTable[DR][Rks] = 0; - break; - default: -#ifdef USE_SPEC_ENV_SPEED - dphaseDRTable[DR][Rks] = rate_adjust (decaytable[RM][RL]); -#else - dphaseDRTable[DR][Rks] = rate_adjust ((RL + 4) << (RM - 1)); -#endif - break; - } - } -} - -static void -makeRksTable (void) -{ - - e_int32 fnum8, block, KR; - - for (fnum8 = 0; fnum8 < 2; fnum8++) - for (block = 0; block < 8; block++) - for (KR = 0; KR < 2; KR++) - { - if(KR != 0) - rksTable[fnum8][block][KR] = (block << 1) + fnum8; - else - rksTable[fnum8][block][KR] = block >> 1; - } -} - -/************************************************************ - - Calc Parameters - -************************************************************/ - -INLINE static e_uint32 -calc_eg_dphase (OPLL_SLOT * slot) -{ - - switch (slot->eg_mode) - { - case ATTACK: - return dphaseARTable[slot->patch.AR][slot->rks]; - - case DECAY: - return dphaseDRTable[slot->patch.DR][slot->rks]; - - case SUSHOLD: - return 0; - - case SUSTINE: - return dphaseDRTable[slot->patch.RR][slot->rks]; - - case RELEASE: - if(slot->sustine) - return dphaseDRTable[5][slot->rks]; - else if(slot->patch.EG) - return dphaseDRTable[slot->patch.RR][slot->rks]; - else - return dphaseDRTable[7][slot->rks]; - - case FINISH: - return 0; - - default: - return 0; - } -} - -/************************************************************* - - OPLL internal interfaces - -*************************************************************/ - -#define UPDATE_PG(S) (S)->dphase = dphaseTable[(S)->fnum][(S)->block][(S)->patch.ML] -#define UPDATE_TLL(S)\ -(((S)->type==0)?\ -((S)->tll = tllTable[((S)->fnum)>>5][(S)->block][(S)->patch.TL][(S)->patch.KL]):\ -((S)->tll = tllTable[((S)->fnum)>>5][(S)->block][(S)->volume][(S)->patch.KL])) -#define UPDATE_RKS(S) (S)->rks = rksTable[((S)->fnum)>>8][(S)->block][(S)->patch.KR] -#define UPDATE_WF(S) (S)->sintbl = waveform[(S)->patch.WF] -#define UPDATE_EG(S) (S)->eg_dphase = calc_eg_dphase(S) -#define UPDATE_ALL(S)\ - UPDATE_PG(S);\ - UPDATE_TLL(S);\ - UPDATE_RKS(S);\ - UPDATE_WF(S); \ - UPDATE_EG(S) /* EG should be updated last. */ - - -/* Slot key on */ -INLINE static void -slotOn (OPLL_SLOT * slot) -{ - slot->eg_mode = ATTACK; - slot->eg_phase = 0; - slot->phase = 0; -} - -/* Slot key on without reseting the phase */ -INLINE static void -slotOn2 (OPLL_SLOT * slot) -{ - slot->eg_mode = ATTACK; - slot->eg_phase = 0; -} - -/* Slot key off */ -INLINE static void -slotOff (OPLL_SLOT * slot) -{ - if(slot->eg_mode == ATTACK) - slot->eg_phase = EXPAND_BITS (AR_ADJUST_TABLE[HIGHBITS (slot->eg_phase, EG_DP_BITS - EG_BITS)], EG_BITS, EG_DP_BITS); - slot->eg_mode = RELEASE; -} - -/* Channel key on */ -INLINE static void -keyOn (OPLL * opll, e_int32 i) -{ - if(!opll->slot_on_flag[i * 2]) - slotOn (MOD(opll,i)); - if(!opll->slot_on_flag[i * 2 + 1]) - slotOn (CAR(opll,i)); - opll->key_status[i] = 1; -} - -/* Channel key off */ -INLINE static void -keyOff (OPLL * opll, e_int32 i) -{ - if(opll->slot_on_flag[i * 2 + 1]) - slotOff (CAR(opll,i)); - opll->key_status[i] = 0; -} - -/* Set sustine parameter */ -INLINE static void -setSustine (OPLL * opll, e_int32 c, e_int32 sustine) -{ - CAR(opll,c)->sustine = sustine; - if(MOD(opll,c)->type) - MOD(opll,c)->sustine = sustine; -} - -/* Volume : 6bit ( Volume register << 2 ) */ -INLINE static void -setVolume (OPLL * opll, e_int32 c, e_int32 volume) -{ - CAR(opll,c)->volume = volume; -} - -INLINE static void -setSlotVolume (OPLL_SLOT * slot, e_int32 volume) -{ - slot->volume = volume; -} - -/* Set F-Number ( fnum : 9bit ) */ -INLINE static void -setFnumber (OPLL * opll, e_int32 c, e_int32 fnum) -{ - CAR(opll,c)->fnum = fnum; - MOD(opll,c)->fnum = fnum; -} - -/* Set Block data (block : 3bit ) */ -INLINE static void -setBlock (OPLL * opll, e_int32 c, e_int32 block) -{ - CAR(opll,c)->block = block; - MOD(opll,c)->block = block; -} - -INLINE static void update_key_status (OPLL * opll) -{ - int ch; - - for (ch = 0; ch < 6; ch++) - opll->slot_on_flag[ch * 2] = opll->slot_on_flag[ch * 2 + 1] = (opll->HiFreq[ch]) & 0x10; -} - -/*********************************************************** - - Initializing - -***********************************************************/ - -static void -OPLL_SLOT_reset (OPLL_SLOT * slot, int type) -{ - slot->type = type; - slot->sintbl = waveform[0]; - slot->phase = 0; - slot->dphase = 0; - slot->output[0] = 0; - slot->output[1] = 0; - slot->feedback = 0; - slot->eg_mode = SETTLE; - slot->eg_phase = EG_DP_WIDTH; - slot->eg_dphase = 0; - slot->rks = 0; - slot->tll = 0; - slot->sustine = 0; - slot->fnum = 0; - slot->block = 0; - slot->volume = 0; - slot->pgout = 0; - slot->egout = 0; -} - -static void -internal_refresh (void) -{ - makeDphaseTable (); - makeDphaseARTable (); - makeDphaseDRTable (); - pm_dphase = (e_uint32) rate_adjust (PM_SPEED * PM_DP_WIDTH / (clk / 72)); - am_dphase = (e_uint32) rate_adjust (AM_SPEED * AM_DP_WIDTH / (clk / 72)); -} - -static void -maketables (e_uint32 c, e_uint32 r) -{ - if(c != clk) - { - clk = c; - makePmTable (); - makeAmTable (); - makeDB2LinTable (); - makeAdjustTable (); - makeTllTable (); - makeRksTable (); - makeSinTable (); - //makeDefaultPatch (); - } - - if(r != rate) - { - rate = r; - internal_refresh (); - } -} - -OPLL *OPLL_new (e_uint32 clk, e_uint32 rate) -{ - OPLL *opll; - - maketables (clk, rate); - - opll = (OPLL *) calloc (sizeof (OPLL), 1); - if(opll == NULL) - return NULL; - - opll->mask = 0; - - OPLL_reset (opll); - - return opll; -} - - -void -OPLL_delete (OPLL * opll) -{ - free (opll); -} - -/* Reset whole of OPLL except patch datas. */ -void -OPLL_reset (OPLL * opll) -{ - e_int32 i; - - if(!opll) - return; - - opll->adr = 0; - opll->out = 0; - - opll->pm_phase = 0; - opll->am_phase = 0; - - opll->mask = 0; - - for (i = 0; i < 12; i++) - OPLL_SLOT_reset(&opll->slot[i], i%2); - - for (i = 0; i < 6; i++) - { - opll->key_status[i] = 0; - //setPatch (opll, i, 0); - } - - for (i = 0; i < 0x40; i++) - OPLL_writeReg (opll, i, 0); - -#ifndef EMU2413_COMPACTION - opll->realstep = (e_uint32) ((1 << 31) / rate); - opll->opllstep = (e_uint32) ((1 << 31) / (clk / 72)); - opll->oplltime = 0; -#endif -} - -/* Force Refresh (When external program changes some parameters). */ -void -OPLL_forceRefresh (OPLL * opll) -{ - e_int32 i; - - if(opll == NULL) - return; - - for (i = 0; i < 12; i++) - { - UPDATE_PG (&opll->slot[i]); - UPDATE_RKS (&opll->slot[i]); - UPDATE_TLL (&opll->slot[i]); - UPDATE_WF (&opll->slot[i]); - UPDATE_EG (&opll->slot[i]); - } -} - -void -OPLL_set_rate (OPLL * opll, e_uint32 r) -{ - if(opll->quality) - rate = 49716; - else - rate = r; - internal_refresh (); - rate = r; -} - -void -OPLL_set_quality (OPLL * opll, e_uint32 q) -{ - opll->quality = q; - OPLL_set_rate (opll, rate); -} - -/********************************************************* - - Generate wave data - -*********************************************************/ -/* Convert Amp(0 to EG_HEIGHT) to Phase(0 to 2PI). */ -#if( SLOT_AMP_BITS - PG_BITS ) > 0 -#define wave2_2pi(e) ( (e) >> ( SLOT_AMP_BITS - PG_BITS )) -#else -#define wave2_2pi(e) ( (e) << ( PG_BITS - SLOT_AMP_BITS )) -#endif - -/* Convert Amp(0 to EG_HEIGHT) to Phase(0 to 4PI). */ -#if( SLOT_AMP_BITS - PG_BITS - 1 ) == 0 -#define wave2_4pi(e) (e) -#elif( SLOT_AMP_BITS - PG_BITS - 1 ) > 0 -#define wave2_4pi(e) ( (e) >> ( SLOT_AMP_BITS - PG_BITS - 1 )) -#else -#define wave2_4pi(e) ( (e) << ( 1 + PG_BITS - SLOT_AMP_BITS )) -#endif - -/* Convert Amp(0 to EG_HEIGHT) to Phase(0 to 8PI). */ -#if( SLOT_AMP_BITS - PG_BITS - 2 ) == 0 -#define wave2_8pi(e) (e) -#elif( SLOT_AMP_BITS - PG_BITS - 2 ) > 0 -#define wave2_8pi(e) ( (e) >> ( SLOT_AMP_BITS - PG_BITS - 2 )) -#else -#define wave2_8pi(e) ( (e) << ( 2 + PG_BITS - SLOT_AMP_BITS )) -#endif - - - -/* Update AM, PM unit */ -static void -update_ampm (OPLL * opll) -{ - opll->pm_phase = (opll->pm_phase + pm_dphase) & (PM_DP_WIDTH - 1); - opll->am_phase = (opll->am_phase + am_dphase) & (AM_DP_WIDTH - 1); - opll->lfo_am = amtable[HIGHBITS (opll->am_phase, AM_DP_BITS - AM_PG_BITS)]; - opll->lfo_pm = pmtable[HIGHBITS (opll->pm_phase, PM_DP_BITS - PM_PG_BITS)]; -} - -/* PG */ -INLINE static void -calc_phase (OPLL_SLOT * slot, e_int32 lfo) -{ - if(slot->patch.PM) - slot->phase += (slot->dphase * lfo) >> PM_AMP_BITS; - else - slot->phase += slot->dphase; - - slot->phase &= (DP_WIDTH - 1); - - slot->pgout = HIGHBITS (slot->phase, DP_BASE_BITS); -} - -/* EG */ -static void -calc_envelope (OPLL_SLOT * slot, e_int32 lfo) -{ -#define S2E(x) (SL2EG((e_int32)(x/SL_STEP))<<(EG_DP_BITS-EG_BITS)) - - static e_uint32 SL[16] = { - S2E (0.0), S2E (3.0), S2E (6.0), S2E (9.0), S2E (12.0), S2E (15.0), S2E (18.0), S2E (21.0), - S2E (24.0), S2E (27.0), S2E (30.0), S2E (33.0), S2E (36.0), S2E (39.0), S2E (42.0), S2E (48.0) - }; - - e_uint32 egout; - - switch (slot->eg_mode) - { - - case ATTACK: - egout = AR_ADJUST_TABLE[HIGHBITS (slot->eg_phase, EG_DP_BITS - EG_BITS)]; - slot->eg_phase += slot->eg_dphase; - if((EG_DP_WIDTH & slot->eg_phase)||(slot->patch.AR==15)) - { - egout = 0; - slot->eg_phase = 0; - slot->eg_mode = DECAY; - UPDATE_EG (slot); - } - break; - - case DECAY: - egout = HIGHBITS (slot->eg_phase, EG_DP_BITS - EG_BITS); - slot->eg_phase += slot->eg_dphase; - if(slot->eg_phase >= SL[slot->patch.SL]) - { - if(slot->patch.EG) - { - slot->eg_phase = SL[slot->patch.SL]; - slot->eg_mode = SUSHOLD; - UPDATE_EG (slot); - } - else - { - slot->eg_phase = SL[slot->patch.SL]; - slot->eg_mode = SUSTINE; - UPDATE_EG (slot); - } - } - break; - - case SUSHOLD: - egout = HIGHBITS (slot->eg_phase, EG_DP_BITS - EG_BITS); - if(slot->patch.EG == 0) - { - slot->eg_mode = SUSTINE; - UPDATE_EG (slot); - } - break; - - case SUSTINE: - case RELEASE: - egout = HIGHBITS (slot->eg_phase, EG_DP_BITS - EG_BITS); - slot->eg_phase += slot->eg_dphase; - if(egout >= (1 << EG_BITS)) - { - slot->eg_mode = FINISH; - egout = (1 << EG_BITS) - 1; - } - break; - - case FINISH: - egout = (1 << EG_BITS) - 1; - break; - - default: - egout = (1 << EG_BITS) - 1; - break; - } - - if(slot->patch.AM) - egout = EG2DB (egout + slot->tll) + lfo; - else - egout = EG2DB (egout + slot->tll); - - if(egout >= DB_MUTE) - egout = DB_MUTE - 1; - - slot->egout = egout; -} - -/* CARRIOR */ -INLINE static e_int32 -calc_slot_car (OPLL_SLOT * slot, e_int32 fm) -{ - slot->output[1] = slot->output[0]; - - if(slot->egout >= (DB_MUTE - 1)) - { - slot->output[0] = 0; - } - else - { - slot->output[0] = DB2LIN_TABLE[slot->sintbl[(slot->pgout+wave2_8pi(fm))&(PG_WIDTH-1)] + slot->egout]; - } - - return (slot->output[1] + slot->output[0]) >> 1; -} - -/* MODULATOR */ -INLINE static e_int32 -calc_slot_mod (OPLL_SLOT * slot) -{ - e_int32 fm; - - slot->output[1] = slot->output[0]; - - if(slot->egout >= (DB_MUTE - 1)) - { - slot->output[0] = 0; - } - else if(slot->patch.FB != 0) - { - fm = wave2_4pi (slot->feedback) >> (7 - slot->patch.FB); - slot->output[0] = DB2LIN_TABLE[slot->sintbl[(slot->pgout + fm)&(PG_WIDTH-1)] + slot->egout]; - } - else - { - slot->output[0] = DB2LIN_TABLE[slot->sintbl[slot->pgout] + slot->egout]; - } - - slot->feedback = (slot->output[1] + slot->output[0]) >> 1; - - return slot->feedback; - -} - -static INLINE e_int16 calc (OPLL * opll) -{ - e_int32 inst = 0, out = 0; - e_int32 i; - - update_ampm (opll); - - for (i = 0; i < 12; i++) - { - calc_phase(&opll->slot[i],opll->lfo_pm); - calc_envelope(&opll->slot[i],opll->lfo_am); - } - - for (i = 0; i < 6; i++) - if(!(opll->mask & OPLL_MASK_CH (i)) && (CAR(opll,i)->eg_mode != FINISH)) - inst += calc_slot_car (CAR(opll,i), calc_slot_mod(MOD(opll,i))); - - out = inst; - return (e_int16) out; -} - -void moocow(OPLL* opll, e_int32 *buf, e_int32 len, int shift) -{ - while(len > 0) - { - *buf+=(calc(opll)+32768)<quality) - return calc (opll); - - while (opll->realstep > opll->oplltime) - { - opll->oplltime += opll->opllstep; - opll->prev = opll->next; - opll->next = calc (opll); - } - - opll->oplltime -= opll->realstep; - opll->out = (e_int16) (((double) opll->next * (opll->opllstep - opll->oplltime) - + (double) opll->prev * opll->oplltime) / opll->opllstep); - - return (e_int16) opll->out; -} -#endif - -e_uint32 -OPLL_setMask (OPLL * opll, e_uint32 mask) -{ - e_uint32 ret; - - if(opll) - { - ret = opll->mask; - opll->mask = mask; - return ret; - } - else - return 0; -} - -e_uint32 -OPLL_toggleMask (OPLL * opll, e_uint32 mask) -{ - e_uint32 ret; - - if(opll) - { - ret = opll->mask; - opll->mask ^= mask; - return ret; - } - else - return 0; -} - -/**************************************************** - - I/O Ctrl - -*****************************************************/ - -static void setInstrument(OPLL * opll, e_uint i, e_uint inst) -{ - const e_uint8 *src; - OPLL_PATCH *modp, *carp; - - opll->patch_number[i]=inst; - - if(inst) - src=default_inst[inst-1]; - else - src=opll->CustInst; - - modp=&MOD(opll,i)->patch; - carp=&CAR(opll,i)->patch; - - modp->AM=(src[0]>>7)&1; - modp->PM=(src[0]>>6)&1; - modp->EG=(src[0]>>5)&1; - modp->KR=(src[0]>>4)&1; - modp->ML=(src[0]&0xF); - - carp->AM=(src[1]>>7)&1; - carp->PM=(src[1]>>6)&1; - carp->EG=(src[1]>>5)&1; - carp->KR=(src[1]>>4)&1; - carp->ML=(src[1]&0xF); - - modp->KL=(src[2]>>6)&3; - modp->TL=(src[2]&0x3F); - - carp->KL = (src[3] >> 6) & 3; - carp->WF = (src[3] >> 4) & 1; - - modp->WF = (src[3] >> 3) & 1; - - modp->FB = (src[3]) & 7; - - modp->AR = (src[4]>>4)&0xF; - modp->DR = (src[4]&0xF); - - carp->AR = (src[5]>>4)&0xF; - carp->DR = (src[5]&0xF); - - modp->SL = (src[6]>>4)&0xF; - modp->RR = (src[6]&0xF); - - carp->SL = (src[7]>>4)&0xF; - carp->RR = (src[7]&0xF); -} - - -void -OPLL_writeReg (OPLL * opll, e_uint32 reg, e_uint32 data) -{ - - e_int32 i, v, ch; - - data = data & 0xff; - reg = reg & 0x3f; - - switch (reg) - { - case 0x00: - opll->CustInst[0]=data; - for (i = 0; i < 6; i++) - { - if(opll->patch_number[i] == 0) - { - setInstrument(opll, i, 0); - UPDATE_PG (MOD(opll,i)); - UPDATE_RKS (MOD(opll,i)); - UPDATE_EG (MOD(opll,i)); - } - } - break; - - case 0x01: - opll->CustInst[1]=data; - for (i = 0; i < 6; i++) - { - if(opll->patch_number[i] == 0) - { - setInstrument(opll, i, 0); - UPDATE_PG (CAR(opll,i)); - UPDATE_RKS (CAR(opll,i)); - UPDATE_EG (CAR(opll,i)); - } - } - break; - - case 0x02: - opll->CustInst[2]=data; - for (i = 0; i < 6; i++) - { - if(opll->patch_number[i] == 0) - { - setInstrument(opll, i, 0); - UPDATE_TLL(MOD(opll,i)); - } - } - break; - - case 0x03: - opll->CustInst[3]=data; - for (i = 0; i < 6; i++) - { - if(opll->patch_number[i] == 0) - { - setInstrument(opll, i, 0); - UPDATE_WF(MOD(opll,i)); - UPDATE_WF(CAR(opll,i)); - } - } - break; - - case 0x04: - opll->CustInst[4]=data; - for (i = 0; i < 6; i++) - { - if(opll->patch_number[i] == 0) - { - setInstrument(opll, i, 0); - UPDATE_EG (MOD(opll,i)); - } - } - break; - - case 0x05: - opll->CustInst[5]=data; - for (i = 0; i < 6; i++) - { - if(opll->patch_number[i] == 0) - { - setInstrument(opll, i, 0); - UPDATE_EG(CAR(opll,i)); - } - } - break; - - case 0x06: - opll->CustInst[6]=data; - for (i = 0; i < 6; i++) - { - if(opll->patch_number[i] == 0) - { - setInstrument(opll, i, 0); - UPDATE_EG (MOD(opll,i)); - } - } - break; - - case 0x07: - opll->CustInst[7]=data; - for (i = 0; i < 6; i++) - { - if(opll->patch_number[i] == 0) - { - setInstrument(opll, i, 0); - UPDATE_EG (CAR(opll,i)); - } - } - break; - - case 0x10: - case 0x11: - case 0x12: - case 0x13: - case 0x14: - case 0x15: - ch = reg - 0x10; - opll->LowFreq[ch]=data; - setFnumber (opll, ch, data + ((opll->HiFreq[ch] & 1) << 8)); - UPDATE_ALL (MOD(opll,ch)); - UPDATE_ALL (CAR(opll,ch)); - break; - - case 0x20: - case 0x21: - case 0x22: - case 0x23: - case 0x24: - case 0x25: - ch = reg - 0x20; - opll->HiFreq[ch]=data; - - setFnumber (opll, ch, ((data & 1) << 8) + opll->LowFreq[ch]); - setBlock (opll, ch, (data >> 1) & 7); - setSustine (opll, ch, (data >> 5) & 1); - if(data & 0x10) - keyOn (opll, ch); - else - keyOff (opll, ch); - UPDATE_ALL (MOD(opll,ch)); - UPDATE_ALL (CAR(opll,ch)); - update_key_status (opll); - break; - - case 0x30: - case 0x31: - case 0x32: - case 0x33: - case 0x34: - case 0x35: - opll->InstVol[reg-0x30]=data; - i = (data >> 4) & 15; - v = data & 15; - setInstrument(opll, reg-0x30, i); - setVolume (opll, reg - 0x30, v << 2); - UPDATE_ALL (MOD(opll,reg - 0x30)); - UPDATE_ALL (CAR(opll,reg - 0x30)); - break; - - default: - break; - - } -} - -void -OPLL_writeIO (OPLL * opll, e_uint32 adr, e_uint32 val) -{ - if(adr & 1) - OPLL_writeReg (opll, opll->adr, val); - else - opll->adr = val; -} - diff --git a/mappers/emu2413.h b/mappers/emu2413.h deleted file mode 100644 index 906b4c5a..00000000 --- a/mappers/emu2413.h +++ /dev/null @@ -1,134 +0,0 @@ -#ifndef _EMU2413_H_ -#define _EMU2413_H_ - -#include "emutypes.h" - -#ifdef EMU2413_DLL_EXPORTS - #define EMU2413_API __declspec(dllexport) -#elif defined(EMU2413_DLL_IMPORTS) - #define EMU2413_API __declspec(dllimport) -#else - #define EMU2413_API -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#define PI 3.14159265358979323846 - -enum {OPLL_VRC7_TONE=0} ; - -/* voice data */ -typedef struct { - e_uint32 TL,FB,EG,ML,AR,DR,SL,RR,KR,KL,AM,PM,WF ; -} OPLL_PATCH ; - -/* slot */ -typedef struct { - - OPLL_PATCH patch; - - e_int32 type ; /* 0 : modulator 1 : carrier */ - - /* OUTPUT */ - e_int32 feedback ; - e_int32 output[2] ; /* Output value of slot */ - - /* for Phase Generator (PG) */ - e_uint16 *sintbl ; /* Wavetable */ - e_uint32 phase ; /* Phase */ - e_uint32 dphase ; /* Phase increment amount */ - e_uint32 pgout ; /* output */ - - /* for Envelope Generator (EG) */ - e_int32 fnum ; /* F-Number */ - e_int32 block ; /* Block */ - e_int32 volume ; /* Current volume */ - e_int32 sustine ; /* Sustine 1 = ON, 0 = OFF */ - e_uint32 tll ; /* Total Level + Key scale level*/ - e_uint32 rks ; /* Key scale offset (Rks) */ - e_int32 eg_mode ; /* Current state */ - e_uint32 eg_phase ; /* Phase */ - e_uint32 eg_dphase ; /* Phase increment amount */ - e_uint32 egout ; /* output */ - -} OPLL_SLOT ; - -/* Mask */ -#define OPLL_MASK_CH(x) (1<<(x)) - -/* opll */ -typedef struct { - - e_uint32 adr ; - e_int32 out ; - -#ifndef EMU2413_COMPACTION - e_uint32 realstep ; - e_uint32 oplltime ; - e_uint32 opllstep ; - e_int32 prev, next ; -#endif - - /* Register */ - e_uint8 LowFreq[6]; - e_uint8 HiFreq[6]; - e_uint8 InstVol[6]; - - e_uint8 CustInst[8]; - - e_int32 slot_on_flag[6 * 2] ; - - /* Pitch Modulator */ - e_uint32 pm_phase ; - e_int32 lfo_pm ; - - /* Amp Modulator */ - e_int32 am_phase ; - e_int32 lfo_am ; - - e_uint32 quality; - - /* Channel Data */ - e_int32 patch_number[6]; - e_int32 key_status[6] ; - - /* Slot */ - OPLL_SLOT slot[6 * 2] ; - - e_uint32 mask ; - -} OPLL ; - -/* Create Object */ -EMU2413_API OPLL *OPLL_new(e_uint32 clk, e_uint32 rate) ; -EMU2413_API void OPLL_delete(OPLL *) ; - -/* Setup */ -EMU2413_API void OPLL_reset(OPLL *) ; -EMU2413_API void OPLL_set_rate(OPLL *opll, e_uint32 r) ; -EMU2413_API void OPLL_set_quality(OPLL *opll, e_uint32 q) ; - -/* Port/Register access */ -EMU2413_API void OPLL_writeIO(OPLL *, e_uint32 reg, e_uint32 val) ; -EMU2413_API void OPLL_writeReg(OPLL *, e_uint32 reg, e_uint32 val) ; - -/* Synthsize */ -EMU2413_API e_int16 OPLL_calc(OPLL *) ; - -/* Misc */ -EMU2413_API void OPLL_forceRefresh(OPLL *) ; - -/* Channel Mask */ -EMU2413_API e_uint32 OPLL_setMask(OPLL *, e_uint32 mask) ; -EMU2413_API e_uint32 OPLL_toggleMask(OPLL *, e_uint32 mask) ; - - -void moocow(OPLL* opll, e_int32 *buf, e_int32 len, int shift); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/mappers/emutypes.h b/mappers/emutypes.h deleted file mode 100644 index fdef420f..00000000 --- a/mappers/emutypes.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef _EMUTYPES_H_ -#define _EMUTYPES_H_ - -#ifndef INLINE - -#if defined(_MSC_VER) -#define INLINE __forceinline -#elif defined(__GNUC__) -#define INLINE __inline__ -#elif defined(_MWERKS_) -#define INLINE inline -#else -#define INLINE -#endif -#endif - -#if defined(EMU_DLL_IMPORTS) -#define EMU2149_DLL_IMPORTS -#define EMU2212_DLL_IMPORTS -#define EMU2413_DLL_IMPORTS -#define EMU8950_DLL_IMPORTS -#define EMU76489_DLL_IMPORTS -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef unsigned int e_uint; -typedef signed int e_int; - -typedef unsigned char e_uint8 ; -typedef signed char e_int8 ; - -typedef unsigned short e_uint16 ; -typedef signed short e_int16 ; - -typedef unsigned int e_uint32 ; -typedef signed int e_int32 ; - -#ifdef __cplusplus -} -#endif -#endif diff --git a/mappers/mapinc.h b/mappers/mapinc.h deleted file mode 100644 index 694a7c9c..00000000 --- a/mappers/mapinc.h +++ /dev/null @@ -1,11 +0,0 @@ -#include "../types.h" -#include "../x6502.h" -#include "../fceu.h" -#include "../ppu.h" -#define INESPRIV -#include "../cart.h" -#include "../ines.h" -#include "../memory.h" -#include "../sound.h" -#include "../state.h" -#include diff --git a/mappers/mmc2and4.c b/mappers/mmc2and4.c deleted file mode 100644 index 022d7369..00000000 --- a/mappers/mmc2and4.c +++ /dev/null @@ -1,121 +0,0 @@ -/* 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" - -#define MMC4reg mapbyte1 -#define latcha1 mapbyte2[0] -#define latcha2 mapbyte2[1] - - -static void FP_FASTAPASS(1) latchcheck(uint32 VAddr) -{ - uint8 l,h; - - h=VAddr>>8; - - if(h>=0x20 || ((h&0xF)!=0xF)) - return; - - l=VAddr&0xF0; - - if(h<0x10) - { - if(l==0xD0) - { - VROM_BANK4(0x0000,MMC4reg[0]); - latcha1=0xFD; - } - else if(l==0xE0) - { - VROM_BANK4(0x0000,MMC4reg[1]); - latcha1=0xFE; - } - } - else - { - if(l==0xD0) - { - VROM_BANK4(0x1000,MMC4reg[2]); - latcha2=0xFD; - } - else if(l==0xE0) - { - VROM_BANK4(0x1000,MMC4reg[3]); - latcha2=0xFE; - } - } -} - -DECLFW(Mapper9_write) // $Axxx -{ - ROM_BANK8(0x8000,V); -} - -DECLFW(Mapper10_write) -{ - ROM_BANK16(0x8000,V); -} - -DECLFW(Mapper9and10_write) -{ - switch(A&0xF000) - { - case 0xB000: - if(latcha1==0xFD) { VROM_BANK4(0x0000,V);} - MMC4reg[0]=V; - break; - case 0xC000: - if(latcha1==0xFE) {VROM_BANK4(0x0000,V);} - MMC4reg[1]=V; - break; - case 0xD000: - if(latcha2==0xFD) {VROM_BANK4(0x1000,V);} - MMC4reg[2]=V; - break; - case 0xE000: - if(latcha2==0xFE) {VROM_BANK4(0x1000,V);} - MMC4reg[3]=V; - break; - case 0xF000: - MIRROR_SET(V&1); - break; - } -} - -void Mapper9_init(void) -{ - latcha1=0xFE; - latcha2=0xFE; - ROM_BANK8(0xA000,~2); - ROM_BANK8(0x8000,0); - SetWriteHandler(0xA000,0xAFFF,Mapper9_write); - SetWriteHandler(0xB000,0xFFFF,Mapper9and10_write); - PPU_hook=latchcheck; -} - -void Mapper10_init(void) -{ - latcha1=latcha2=0xFE; - SetWriteHandler(0xA000,0xAFFF,Mapper10_write); - SetWriteHandler(0xB000,0xFFFF,Mapper9and10_write); - PPU_hook=latchcheck; -} - diff --git a/mappers/simple.c b/mappers/simple.c deleted file mode 100644 index c393d095..00000000 --- a/mappers/simple.c +++ /dev/null @@ -1,100 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 1998 BERO - * 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 latche; - -static DECLFW(Mapper34_write) -{ - switch(A) - { - case 0x7FFD:ROM_BANK32(V);break; - case 0x7FFE:VROM_BANK4(0x0000,V);break; - case 0x7fff:VROM_BANK4(0x1000,V);break; - } - if(A>=0x8000) - ROM_BANK32(V); -} - -void Mapper34_init(void) -{ - ROM_BANK32(0); - SetWriteHandler(0x7ffd,0xffff,Mapper34_write); -} - -/* I might want to add some code to the mapper 96 PPU hook function - to not change CHR banks if the attribute table is being accessed, - if I make emulation a little more accurate in the future. -*/ - -static uint8 M96LA; -static DECLFW(Mapper96_write) -{ - latche=V; - setprg32(0x8000,V&3); - setchr4r(0x10,0x0000,(latche&4)|M96LA); - setchr4r(0x10,0x1000,(latche&4)|3); -} - -static void FP_FASTAPASS(1) M96Hook(uint32 A) -{ - if((A&0x3000)!=0x2000) return; - //if((A&0x3ff)>=0x3c0) return; - M96LA=(A>>8)&3; - setchr4r(0x10,0x0000,(latche&4)|M96LA); -} - -static void M96Sync(int v) -{ - setprg32(0x8000,latche&3); - setchr4r(0x10,0x0000,(latche&4)|M96LA); - setchr4r(0x10,0x1000,(latche&4)|3); -} - -void Mapper96_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper96_write); - PPU_hook=M96Hook; - AddExState(&latche, 1, 0, "LATC"); - AddExState(&M96LA, 1, 0, "LAVA"); - SetupCartCHRMapping(0x10, MapperExRAM, 32768, 1); - latche=M96LA=0; - M96Sync(0); - setmirror(MI_0); - GameStateRestore=M96Sync; -} - -static DECLFW(M156Write) -{ - if(A>=0xc000 && A<=0xC003) - VROM_BANK1((A&3)*1024,V); - else if(A>=0xc008 && A<=0xc00b) - VROM_BANK1(0x1000+(A&3)*1024,V); - if(A==0xc010) ROM_BANK16(0x8000,V); -// printf("$%04x:$%02x\n",A,V); -} - -void Mapper156_init(void) -{ - onemir(0); - SetWriteHandler(0xc000,0xc010,M156Write); -} diff --git a/mappers/vrc7tone.h b/mappers/vrc7tone.h deleted file mode 100644 index d1363073..00000000 --- a/mappers/vrc7tone.h +++ /dev/null @@ -1,17 +0,0 @@ -/* VRC7 instruments, January 17, 2004 update -Xodnizel */ - {0x03, 0x21, 0x04, 0x06, 0x8D, 0xF2, 0x42, 0x17}, - {0x13, 0x41, 0x05, 0x0E, 0x99, 0x96, 0x63, 0x12}, - {0x31, 0x11, 0x10, 0x0A, 0xF0, 0x9C, 0x32, 0x02}, - {0x21, 0x61, 0x1D, 0x07, 0x9F, 0x64, 0x20, 0x27}, - {0x22, 0x21, 0x1E, 0x06, 0xF0, 0x76, 0x08, 0x28}, - {0x02, 0x01, 0x06, 0x00, 0xF0, 0xF2, 0x03, 0x95}, - {0x21, 0x61, 0x1C, 0x07, 0x82, 0x81, 0x16, 0x07}, - {0x23, 0x21, 0x1A, 0x17, 0xEF, 0x82, 0x25, 0x15}, - {0x25, 0x11, 0x1F, 0x00, 0x86, 0x41, 0x20, 0x11}, - {0x85, 0x01, 0x1F, 0x0F, 0xE4, 0xA2, 0x11, 0x12}, - {0x07, 0xC1, 0x2B, 0x45, 0xB4, 0xF1, 0x24, 0xF4}, - {0x61, 0x23, 0x11, 0x06, 0x96, 0x96, 0x13, 0x16}, - {0x01, 0x02, 0xD3, 0x05, 0x82, 0xA2, 0x31, 0x51}, - {0x61, 0x22, 0x0D, 0x02, 0xC3, 0x7F, 0x24, 0x05}, - {0x21, 0x62, 0x0E, 0x00, 0xA1, 0xA0, 0x44, 0x17}, - diff --git a/memory.c b/memory.c index a0a33e2d..28694071 100644 --- a/memory.c +++ b/memory.c @@ -73,8 +73,8 @@ void FASTAPASS(3) FCEU_memmove(void *d, void *s, uint32 l) { uint8 *tmpd, *tmps; - tmpd = d; - tmps = s; + tmpd = (uint8*)d; //mbg merge 7/17/06 added cast + tmps = (uint8*)s; //mbg merge 7/17/06 added cast for(x=l;x;x--) // This could be optimized further, though(more tests could be performed). { @@ -87,8 +87,8 @@ void FASTAPASS(3) FCEU_memmove(void *d, void *s, uint32 l) { uint32 *tmpd, *tmps; - tmpd = d; - tmps = s; + tmpd = (uint32*)d; //mbg merge 7/17/06 added cast + tmps = (uint32*)s; //mbg merge 7/17/06 added cast for(x=l>>2;x;x--) { diff --git a/movie.c b/movie.c index 1844beb7..97b1409f 100644 --- a/movie.c +++ b/movie.c @@ -1,7 +1,7 @@ #include #include #include -#include +//#include //mbgm erge 7/17/06 removed #ifdef WIN32 #include #endif @@ -16,6 +16,7 @@ #include "general.h" #include "video.h" #include "movie.h" +#include "memory.h" //mbg merge 7/17/06 added #define MOVIE_MAGIC 0x1a4d4346 // FCM\x1a #define MOVIE_VERSION 2 // still at 2 since the format itself is still compatible - to detect which version the movie was made with, check the fceu version stored in the movie header (e.g against FCEU_VERSION_NUMERIC) @@ -294,7 +295,7 @@ static const char* convertToFCM(const char *fname, char *buffer) if(file) { fseek(file, 12, SEEK_SET); - int frames=0; + uint32 frames=0; //mbg merge 7/17/06 changed to uint32 read32le(&frames, file); if(frames) { @@ -345,6 +346,8 @@ static const char* convertToFCM(const char *fname, char *buffer) return fname; } +void ParseGIInput(FCEUGI *GI); //mbg merge 7/17/06 - had to add. gross. +void InitOtherInput(void); //mbg merge 7/17/06 - had to add. gross. static void ResetInputTypes() { #ifdef WIN32 @@ -839,7 +842,7 @@ void FCEUI_SelectMovieNext(int n) int FCEUI_SelectMovie(int w, int show) { int oldslot=CurrentMovie; - if(w == -1) { MovieShow = 0; return; } + if(w == -1) { MovieShow = 0; return 0; } //mbg merge 7/17/06 had to add return value FCEUI_SelectState(-1,0); CurrentMovie=w; @@ -855,6 +858,7 @@ int FCEUI_SelectMovie(int w, int show) else FCEU_DispMessage("-select movie-"); } + return 0; //mbg merge 7/17/06 had to add return value } int movcounter=0; @@ -1127,7 +1131,7 @@ int FCEUI_MovieGetInfo(const char* fname, MOVIE_INFO* info) { char str[256]; size_t r; - int p; + uint32 p; //mbg merge 7/17/06 change to uint32 int p2=0; char last_c=32; @@ -1374,7 +1378,7 @@ static int FCEUI_MovieGetInfo_v1(const char* fname, MOVIE_INFO* info) metadata_length = (int)savestateoffset - MOVIE_V1_HEADER_SIZE; if(metadata_length > 0) { - int i; + //int i; //mbg merge 7/17/06 removed metadata_length >>= 1; if(metadata_length >= MOVIE_MAX_METADATA) @@ -1393,12 +1397,10 @@ static int FCEUI_MovieGetInfo_v1(const char* fname, MOVIE_INFO* info) while(ptr=ptr_end) ptr_end=ptr; else @@ -1406,8 +1408,7 @@ static int FCEUI_MovieGetInfo_v1(const char* fname, MOVIE_INFO* info) *ptr++=(0xc0 | (c>>6)); *ptr++=(0x80 | (c & 0x3f)); } - break; - case 0x800 ... 0xffff: + else if(ptr+2>=ptr_end) ptr_end=ptr; else @@ -1416,8 +1417,7 @@ static int FCEUI_MovieGetInfo_v1(const char* fname, MOVIE_INFO* info) *ptr++=(0x80 | ((c>>6) & 0x3f)); *ptr++=(0x80 | (c & 0x3f)); } - break; - } + c_ptr++; } *ptr='\0'; diff --git a/netplay.c b/netplay.c index 6b3e7d9a..61842568 100644 --- a/netplay.c +++ b/netplay.c @@ -24,7 +24,7 @@ #include #include #include -#include +//#include //mbg merge 7/17/06 removed #include #include "types.h" @@ -80,7 +80,10 @@ int FCEUI_NetplayStart(int nlocal, int divisor) int FCEUNET_SendCommand(uint8 cmd, uint32 len) { - uint8 buf[numlocal + 1 + 4]; + //mbg merge 7/17/06 changed to alloca + //uint8 buf[numlocal + 1 + 4]; + uint8 *buf = (uint8*)_alloca(numlocal+1+4); + buf[0] = 0xFF; FCEU_en32lsb(&buf[numlocal], len); @@ -99,7 +102,7 @@ void FCEUI_NetplayText(uint8 *text) { uint32 len; - len = strlen(text); + len = strlen((char*)text); //mbg merge 7/17/06 added cast if(!FCEUNET_SendCommand(FCEUNPCMD_TEXT,len)) return; @@ -119,13 +122,13 @@ int FCEUNET_SendFile(uint8 cmd, char *fn) fstat(fileno(fp),&sb); len = sb.st_size; - buf = malloc(len); + buf = (char*)malloc(len); //mbg merge 7/17/06 added cast fread(buf, 1, len, fp); fclose(fp); - cbuf = malloc(4 + len + len / 1000 + 12); - FCEU_en32lsb(cbuf, len); - compress2(cbuf + 4, &clen, buf, len, 7); + cbuf = (char*)malloc(4 + len + len / 1000 + 12); //mbg merge 7/17/06 added cast + FCEU_en32lsb((uint8*)cbuf, len); //mbg merge 7/17/06 added cast + compress2((uint8*)cbuf + 4, &clen, (uint8*)buf, len, 7); //mbg merge 7/17/06 added casts free(buf); //printf("Sending file: %s, %d, %d\n",fn,len,clen); @@ -169,7 +172,7 @@ static FILE *FetchFile(uint32 remlen) fn = FCEU_MakeFName(FCEUMKF_NPTEMP,0,0); if((fp = fopen(fn,"w+b"))) { - cbuf = malloc(clen); + cbuf = (char *)malloc(clen); //mbg merge 7/17/06 added cast if(!FCEUD_RecvData(cbuf, clen)) { NetError(); @@ -180,7 +183,7 @@ static FILE *FetchFile(uint32 remlen) return(0); } - len = FCEU_de32lsb(cbuf); + len = FCEU_de32lsb((uint8*)cbuf); //mbg merge 7/17/06 added cast if(len > 500000) // Another sanity check { NetError(); @@ -190,8 +193,8 @@ static FILE *FetchFile(uint32 remlen) free(fn); return(0); } - buf = malloc(len); - uncompress(buf, &len, cbuf + 4, clen - 4); + buf = (char *)malloc(len); //mbg merge 7/17/06 added cast + uncompress((uint8*)buf, &len, (uint8*)cbuf + 4, clen - 4); //mbg merge 7/17/06 added casts fwrite(buf, 1, len, fp); free(buf); @@ -244,7 +247,7 @@ void NetplayUpdate(uint8 *joyp) NetError(); return; } - tbuf = malloc(len + 1); + tbuf = (uint8*)malloc(len + 1); //mbg merge 7/17/06 added cast tbuf[len] = 0; if(!FCEUD_RecvData(tbuf, len)) { diff --git a/nsf.c b/nsf.c index 1eeeec10..8852b369 100644 --- a/nsf.c +++ b/nsf.c @@ -218,9 +218,9 @@ int NSFLoad(FCEUFILE *fp) FCEU_printf(" Starting song: %d / %d\n\n",NSFHeader.StartingSong,NSFHeader.TotalSongs); if(NSFHeader.SoundChip&4) - ExWRAM=FCEU_gmalloc(32768+8192); + ExWRAM=(uint8*)FCEU_gmalloc(32768+8192); //mbg merge 7/17/06 added cast else - ExWRAM=FCEU_gmalloc(8192); + ExWRAM=(uint8*)FCEU_gmalloc(8192); //mbg merge 7/17/06 added cast FCEUI_SetVidSystem(NSFHeader.VideoSystem); @@ -561,8 +561,8 @@ int FCEUI_NSFChange(int amount) /* Returns total songs */ int FCEUI_NSFGetInfo(uint8 *name, uint8 *artist, uint8 *copyright, int maxlen) { - strncpy(name,NSFHeader.SongName,maxlen); - strncpy(artist,NSFHeader.Artist,maxlen); - strncpy(copyright,NSFHeader.Copyright,maxlen); + strncpy((char*)name,(char*)NSFHeader.SongName,maxlen); //mbg merge 7/17/06 added casts + strncpy((char*)artist,(char*)NSFHeader.Artist,maxlen); //mbg merge 7/17/06 added casts + strncpy((char*)copyright,(char*)NSFHeader.Copyright,maxlen); //mbg merge 7/17/06 added casts return(NSFHeader.TotalSongs); } diff --git a/sound.c b/sound.c index d1ed5268..b16ae727 100644 --- a/sound.c +++ b/sound.c @@ -540,7 +540,7 @@ fhcnt-=cycles*48; void RDoPCM(void) { - int32 V; + uint32 V; //mbg merge 7/17/06 made uint32 for(V=ChannelBC[4];V #include #include -#include +//#include //mbg merge 7/17/06 removed #include "types.h" #include "x6502.h" @@ -205,6 +205,8 @@ static int ReadStateChunk(FILE *st, SFORMAT *sf, int size) static int read_sfcpuc=0, read_snd=0; +void FCEUD_BlitScreen(uint8 *XBuf); //mbg merge 7/17/06 YUCKY had to add +void UpdateFCEUWindow(void); //mbg merge 7/17/06 YUCKY had to add static int ReadStateChunks(FILE *st, int32 totalsize) { int t; @@ -615,7 +617,7 @@ void FCEUI_SelectStateNext(int n) int FCEUI_SelectState(int w, int show) { int oldstate=CurrentState; - if(w == -1) { StateShow = 0; return; } + if(w == -1) { StateShow = 0; return 0; } //mbg merge 7/17/06 had to make return a value FCEUI_SelectMovie(-1,0); CurrentState=w; diff --git a/types.h b/types.h index 01ecbd96..5dbed1d6 100644 --- a/types.h +++ b/types.h @@ -17,24 +17,49 @@ * 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 - */ + */ #ifndef __FCEU_TYPES #define __FCEU_TYPES +#define FCEU_VERSION_NUMERIC 9813 +#define FCEU_VERSION_STRING "1.07" +#define FCEU_VERSION "0.98.13" +#define FCEUMM_VERSION "0.98.13mm" +#define FCEUXD_VERSION_STRING "1.0a" +#define FCEUXDSP_VERSION_STRING "1.07" + +#ifdef MSVC +typedef unsigned char uint8; +typedef unsigned short uint16; +typedef unsigned long uint32; +typedef signed char int8; +typedef signed short int16; +typedef signed long int32; +#include +#include +#include +void* _alloca(size_t amt); //wtf why isnt this in any header +#define dup _dup +#define stat _stat +#define fstat _fstat +#define W_OK 2 +#define R_OK 2 +#define X_OK 1 +#define F_OK 0 +#else +#include +#include +#include #include typedef int8_t int8; typedef int16_t int16; -typedef int32_t int32; +typedef int32_t int32; -typedef uint8_t uint8; +typedef uint8_t uint8; typedef uint16_t uint16; typedef uint32_t uint32; - -//typedef unsigned char uint8; -//typedef unsigned short uint16; -//typedef unsigned long uint32; - +#endif #ifdef __GNUC__ typedef unsigned long long uint64; @@ -44,13 +69,23 @@ typedef uint32_t uint32; #elif MSVC typedef __int64 int64; typedef unsigned __int64 uint64; + #define __restrict__ #define INLINE __inline - #define GINLINE /* Can't declare a function INLINE + #define GINLINE /* Can't declare a function INLINE and global in MSVC. Bummer. */ - #define PSS_STYLE 2 /* Does MSVC compile for anything + #define PSS_STYLE 2 /* Does MSVC compile for anything other than Windows/DOS targets? */ + + #if _MSC_VER >= 1300 + #pragma warning(disable:4244) //warning C4244: '=' : conversion from 'uint32' to 'uint8', possible loss of data + #pragma warning(disable:4996) //'strdup' was declared deprecated +#endif + + #if _MSC_VER < 1400 + #define vsnprintf _vsnprintf + #endif #endif #if PSS_STYLE==2 @@ -70,7 +105,7 @@ typedef uint32_t uint32; #elif PSS_STYLE==4 -#define PSS ":" +#define PSS ":" #define PS ':' #endif @@ -81,8 +116,8 @@ typedef uint32_t uint32; #define FASTAPASS(x) __attribute__((regparm(x))) #define FP_FASTAPASS FASTAPASS #else - #define FASTAPASS(x) - #define FP_FASTAPASS(x) + #define FASTAPASS(x) + #define FP_FASTAPASS(x) #endif #elif MSVC #define FP_FASTAPASS(x) diff --git a/unif.c b/unif.c index 46b66a3c..00e72f63 100644 --- a/unif.c +++ b/unif.c @@ -75,7 +75,7 @@ static uint32 mallocedsizes[32]; static int FixRomSize(uint32 size, uint32 minimum) { - int x=1; + uint32 x=1; //mbg merge 7/17/06 made uint if(sizename) { - FCEUGameInfo->name=malloc(strlen(namebuf)+1); - strcpy(FCEUGameInfo->name,namebuf); + FCEUGameInfo->name=(uint8*)malloc(strlen(namebuf)+1); //mbg merge 7/17/06 added cast + strcpy((char*)FCEUGameInfo->name,namebuf); //mbg merge 7/17/06 added cast } return(1); } diff --git a/video.c b/video.c index c38b372d..90323b18 100644 --- a/video.c +++ b/video.c @@ -55,22 +55,23 @@ HANDLE mapXBuf; void FCEU_KillVirtualVideo(void) { - if(xbsave) - { - free(xbsave); - xbsave=0; - } - if(XBuf) - { - UnmapViewOfFile(XBuf); - CloseHandle(mapXBuf); - mapXBuf=NULL; - } - if(XBackBuf) - { - free(XBackBuf); - XBackBuf=0; - } + //mbg merge TODO 7/17/06 temporarily removed + //if(xbsave) + //{ + // free(xbsave); + // xbsave=0; + //} + //if(XBuf) + //{ + //UnmapViewOfFile(XBuf); + //CloseHandle(mapXBuf); + //mapXBuf=NULL; + //} + //if(XBackBuf) + //{ + // free(XBackBuf); + // XBackBuf=0; + //} } int FCEU_InitVirtualVideo(void) @@ -227,7 +228,7 @@ void FCEU_PutImage(void) { int controller, c, color; int i, j; - char * t=XBuf+(FSettings.LastSLine-9)*256 + 20; + uint8 *t = XBuf+(FSettings.LastSLine-9)*256 + 20; //mbg merge 7/17/06 changed t to uint8* if(input_display > 4) input_display = 4; for(controller = 0; controller < input_display; controller++, t += 56) { diff --git a/wave.c b/wave.c index 43b21e88..62880e84 100644 --- a/wave.c +++ b/wave.c @@ -16,7 +16,10 @@ static long wsize; */ void FCEU_WriteWaveData(int32 *Buffer, int Count) { - int16 temp[Count]; /* Yay. Is this the first use of this "feature" of C in FCE Ultra? */ + //mbg merge 7/17/06 changed to alloca + //int16 temp[Count]; /* Yay. Is this the first use of this "feature" of C in FCE Ultra? */ + int16 *temp = (int16*)_alloca(Count*2); + int16 *dest; int x; @@ -47,7 +50,9 @@ void FCEU_WriteWaveData(int32 *Buffer, int Count) extern int bittage; if(!bittage) { - int8 temp2[Count]; + //mbg merge 7/17/06 changed to alloca + //int8 temp2[Count]; + int8 *temp2 = (int8*)_alloca(Count); int P; for(P=0;P>8))^128; diff --git a/x6502struct.h b/x6502struct.h index 31e726f5..6dca41ce 100644 --- a/x6502struct.h +++ b/x6502struct.h @@ -1,6 +1,5 @@ #ifndef _X6502STRUCTH - -#include "fceu.h" +#define _X6502STRUCTH typedef struct __X6502 { int32 tcount; /* Temporary cycle counter */ @@ -24,5 +23,5 @@ typedef struct __X6502 { #endif } X6502; -#define _X6502STRUCTH + #endif diff --git a/xstring.c b/xstring.c new file mode 100644 index 00000000..37d9e2a3 --- /dev/null +++ b/xstring.c @@ -0,0 +1,186 @@ +/* Extended string routines + * + * Copyright notice for this file: + * Copyright (C) 2004 Jason Oster (Parasyte) + * + * 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 "xstring.h" + + +//Upper case routine +// Returns number of characters modified +int str_ucase(char *str) { + unsigned int i=0,j=0; //mbg merge 7/17/06 changed to unsigned int + + while (i < strlen(str)) { + if ((str[i] >= 'a') && (str[i] <= 'z')) { + str[i] &= ~0x20; + j++; + } + i++; + } + return j; +} + + +//Lower case routine +// Returns number of characters modified +int str_lcase(char *str) { + unsigned int i=0,j=0; //mbg merge 7/17/06 changed to unsigned int + + while (i < strlen(str)) { + if ((str[i] >= 'A') && (str[i] <= 'Z')) { + str[i] |= 0x20; + j++; + } + i++; + } + return j; +} + + +//White space-trimming routine +// Removes whitespace from left side of string, depending on the flags set (See STRIP_x definitions in xstring.h) +// Returns number of characters removed +int str_ltrim(char *str, int flags) { + unsigned int i=0; //mbg merge 7/17/06 changed to unsigned int + + while (str[0]) { + if ((str[0] != ' ') || (str[0] != '\t') || (str[0] != '\r') || (str[0] != '\n')) break; + + if ((flags & STRIP_SP) && (str[0] == ' ')) { + i++; + strcpy(str,str+1); + } + if ((flags & STRIP_TAB) && (str[0] == '\t')) { + i++; + strcpy(str,str+1); + } + if ((flags & STRIP_CR) && (str[0] == '\r')) { + i++; + strcpy(str,str+1); + } + if ((flags & STRIP_LF) && (str[0] == '\n')) { + i++; + strcpy(str,str+1); + } + } + return i; +} + + +//White space-trimming routine +// Removes whitespace from right side of string, depending on the flags set (See STRIP_x definitions in xstring.h) +// Returns number of characters removed +int str_rtrim(char *str, int flags) { + unsigned int i=0; //mbg merge 7/17/06 changed to unsigned int + + while (strlen(str)) { + if ((str[strlen(str)-1] != ' ') || + (str[strlen(str)-1] != '\t') || + (str[strlen(str)-1] != '\r') || + (str[strlen(str)-1] != '\n')) break; + + if ((flags & STRIP_SP) && (str[0] == ' ')) { + i++; + str[strlen(str)-1] = 0; + } + if ((flags & STRIP_TAB) && (str[0] == '\t')) { + i++; + str[strlen(str)-1] = 0; + } + if ((flags & STRIP_CR) && (str[0] == '\r')) { + i++; + str[strlen(str)-1] = 0; + } + if ((flags & STRIP_LF) && (str[0] == '\n')) { + i++; + str[strlen(str)-1] = 0; + } + } + return i; +} + + +//White space-stripping routine +// Removes whitespace depending on the flags set (See STRIP_x definitions in xstring.h) +// Returns number of characters removed, or -1 on error +int str_strip(char *str, int flags) { + unsigned int i=0,j=0; //mbg merge 7/17/06 changed to unsigned int + char *astr,chr; + + if (!strlen(str)) return -1; + if (!(flags & (STRIP_SP|STRIP_TAB|STRIP_CR|STRIP_LF))) return -1; + if (!(astr = (char*)malloc(strlen(str)+1))) return -1; + while (i < strlen(str)) { + chr = str[i++]; + if ((flags & STRIP_SP) && (chr == ' ')) chr = 0; + if ((flags & STRIP_TAB) && (chr == '\t')) chr = 0; + if ((flags & STRIP_CR) && (chr == '\r')) chr = 0; + if ((flags & STRIP_LF) && (chr == '\n')) chr = 0; + + if (chr) astr[j++] = chr; + } + astr[j] = 0; + strcpy(str,astr); + free(astr); + return j; +} + + +//Character replacement routine +// Replaces all instances of 'search' with 'replace' +// Returns number of characters modified +int chr_replace(char *str, char search, char replace) { + unsigned int i=0,j=0; //mbg merge 7/17/06 changed to unsigned int + + while (i < strlen(str)) { + if (str[i] == search) { + str[i] = replace; + j++; + } + i++; + } + return j; +} + + +//Sub-String replacement routine +// Replaces all instances of 'search' with 'replace' +// Returns number of sub-strings modified, or -1 on error +int str_replace(char *str, char *search, char *replace) { + unsigned int i=0,j=0; //mbg merge 7/17/06 changed to unsigned int + int searchlen,replacelen; + char *astr; + + searchlen = strlen(search); + replacelen = strlen(replace); + if ((!strlen(str)) || (!searchlen)) return -1; //note: allow *replace to have a length of zero! + if (!(astr = (char*)malloc(strlen(str)+1))) return -1; + while (i < strlen(str)) { + if (!strncmp(str+i,search,searchlen)) { + if (replacelen) memcpy(astr+j,replace,replacelen); + i += searchlen; + j += replacelen; + } + else astr[j++] = str[i++]; + } + astr[j] = 0; + strcpy(str,astr); + free(astr); + return j; +} diff --git a/boards/novel.c b/xstring.h similarity index 55% rename from boards/novel.c rename to xstring.h index 26e70ec0..32646bca 100644 --- a/boards/novel.c +++ b/xstring.h @@ -1,55 +1,37 @@ -/* 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 latch; - -static void DoNovel(void) -{ - setprg32(0x8000,latch&3); - setchr8(latch&7); -} - -static DECLFW(NovelWrite) -{ - latch=A&0xFF; - DoNovel(); -} - -static void NovelReset(void) -{ - SetWriteHandler(0x8000,0xFFFF,NovelWrite); - SetReadHandler(0x8000,0xFFFF,CartBR); - setprg32(0x8000,0); - setchr8(0); -} - -static void NovelRestore(int version) -{ - DoNovel(); -} - -void Novel_Init(CartInfo *info) -{ - AddExState(&latch, 1, 0,"L1"); - info->Power=NovelReset; - GameStateRestore=NovelRestore; -} +/* Extended string routines + * + * Copyright notice for this file: + * Copyright (C) 2004 Jason Oster (Parasyte) + * + * 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 +#include + +//definitions for str_strip() flags +#define STRIP_SP 0x01 /* space */ +#define STRIP_TAB 0x02 /* tab */ +#define STRIP_CR 0x04 /* carriage return */ +#define STRIP_LF 0x08 /* line feed */ + + +int str_ucase(char *str); +int str_lcase(char *str); +int str_ltrim(char *str, int flags); +int str_rtrim(char *str, int flags); +int str_strip(char *str, int flags); +int chr_replace(char *str, char search, char replace); +int str_replace(char *str, char *search, char *replace);