diff --git a/src/boards/01-222.cpp b/src/boards/01-222.cpp index 30ac3e87..64d2c960 100644 --- a/src/boards/01-222.cpp +++ b/src/boards/01-222.cpp @@ -46,7 +46,7 @@ static SFORMAT StateRegs[] = static void Sync(void) { setprg32(0x8000, (reg[2] >> 2) & 1); if (is172) - setchr8((((cmd ^ reg[2]) >> 3) & 2) | (((cmd ^ reg[2]) >> 5) & 1)); // 1991 DU MA Racing probably CHR bank sequence is WRONG, so it is possible to + setchr8((((cmd ^ reg[2]) >> 3) & 2) | (((cmd ^ reg[2]) >> 5) & 1)); // 1991 DU MA Racing probably CHR bank sequence is WRONG, so it is possible to // rearrange CHR banks for normal UNIF board and mapper 172 is unneccessary else setchr8(reg[2] & 3); diff --git a/src/boards/15.cpp b/src/boards/15.cpp index 5652d225..4aee608a 100644 --- a/src/boards/15.cpp +++ b/src/boards/15.cpp @@ -23,98 +23,87 @@ static uint16 latchea; static uint8 latched; -static uint8 *WRAM=NULL; +static uint8 *WRAM = NULL; static uint32 WRAMSIZE; -static SFORMAT StateRegs[]= +static SFORMAT StateRegs[] = { - {&latchea, 2, "AREG"}, - {&latched, 1, "DREG"}, - {0} + { &latchea, 2, "AREG" }, + { &latched, 1, "DREG" }, + { 0 } }; -static void Sync(void) -{ - int i; - setmirror(((latched>>6)&1)^1); - switch(latchea) - { - case 0x8000: - for(i=0;i<4;i++) - setprg8(0x8000+(i<<13),(((latched&0x7F)<<1)+i)^(latched>>7)); - break; - case 0x8002: - for(i=0;i<4;i++) - setprg8(0x8000+(i<<13),((latched&0x7F)<<1)+(latched>>7)); - break; - case 0x8001: - case 0x8003: - for(i=0;i<4;i++) - { - unsigned int b; - b=latched&0x7F; - if(i>=2 && !(latchea&0x2)) - b=0x7F; - setprg8(0x8000+(i<<13),(i&1)+((b<<1)^(latched>>7))); - } - break; - } +static void Sync(void) { + int i; + setmirror(((latched >> 6) & 1) ^ 1); + switch (latchea) { + case 0x8000: + for (i = 0; i < 4; i++) + setprg8(0x8000 + (i << 13), (((latched & 0x7F) << 1) + i) ^ (latched >> 7)); + break; + case 0x8002: + for (i = 0; i < 4; i++) + setprg8(0x8000 + (i << 13), ((latched & 0x7F) << 1) + (latched >> 7)); + break; + case 0x8001: + case 0x8003: + for (i = 0; i < 4; i++) { + unsigned int b; + b = latched & 0x7F; + if (i >= 2 && !(latchea & 0x2)) + b = 0x7F; + setprg8(0x8000 + (i << 13), (i & 1) + ((b << 1) ^ (latched >> 7))); + } + break; + } } -static DECLFW(M15Write) -{ - latchea=A; - latched=V; -// printf("%04X = %02X\n",A,V); - Sync(); +static DECLFW(M15Write) { + latchea = A; + latched = V; + Sync(); } -static void StateRestore(int version) -{ - Sync(); +static void StateRestore(int version) { + Sync(); } -static void M15Power(void) -{ - latchea=0x8000; - latched=0; - setchr8(0); - setprg8r(0x10,0x6000,0); - SetReadHandler(0x6000,0x7FFF,CartBR); - SetWriteHandler(0x6000,0x7FFF,CartBW); - SetWriteHandler(0x8000,0xFFFF,M15Write); - SetReadHandler(0x8000,0xFFFF,CartBR); - Sync(); +static void M15Power(void) { + latchea = 0x8000; + latched = 0; + setchr8(0); + setprg8r(0x10, 0x6000, 0); + SetReadHandler(0x6000, 0x7FFF, CartBR); + SetWriteHandler(0x6000, 0x7FFF, CartBW); + SetWriteHandler(0x8000, 0xFFFF, M15Write); + SetReadHandler(0x8000, 0xFFFF, CartBR); + Sync(); } -static void M15Reset(void) -{ - latchea=0x8000; - latched=0; - Sync(); +static void M15Reset(void) { + latchea = 0x8000; + latched = 0; + Sync(); } -static void M15Close(void) -{ - if(WRAM) - FCEU_gfree(WRAM); - WRAM=NULL; +static void M15Close(void) { + if (WRAM) + FCEU_gfree(WRAM); + WRAM = NULL; } -void Mapper15_Init(CartInfo *info) -{ - info->Power=M15Power; - info->Reset=M15Reset; - info->Close=M15Close; - GameStateRestore=StateRestore; - WRAMSIZE=8192; - WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1); - if(info->battery) - { - info->SaveGame[0]=WRAM; - info->SaveGameLen[0]=WRAMSIZE; - } - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - AddExState(&StateRegs, ~0, 0, 0); +void Mapper15_Init(CartInfo *info) { + info->Power = M15Power; + info->Reset = M15Reset; + info->Close = M15Close; + GameStateRestore = StateRestore; + WRAMSIZE = 8192; + WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); + SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); + if (info->battery) { + info->SaveGame[0] = WRAM; + info->SaveGameLen[0] = WRAMSIZE; + } + AddExState(WRAM, WRAMSIZE, 0, "WRAM"); + AddExState(&StateRegs, ~0, 0, 0); } diff --git a/src/boards/206.cpp b/src/boards/206.cpp new file mode 100644 index 00000000..b1bb0a1c --- /dev/null +++ b/src/boards/206.cpp @@ -0,0 +1,77 @@ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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) { + 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(M206Write) { + 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 M206Power(void) { + setprg8(0xc000, 0xE); + setprg8(0xe000, 0xF); + cmd = 0; + memset(DRegs, 0, 8); + Sync(); + SetReadHandler(0x8000, 0xFFFF, CartBR); + SetWriteHandler(0x8000, 0xFFFF, M206Write); +} + + +void Mapper206_Init(CartInfo *info) { + info->Power = M206Power; + GameStateRestore = StateRestore; + AddExState(&StateRegs, ~0, 0, 0); +} diff --git a/src/boards/36.cpp b/src/boards/36.cpp new file mode 100644 index 00000000..209d777e --- /dev/null +++ b/src/boards/36.cpp @@ -0,0 +1,63 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2012 CaH4e3 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * TXC/Micro Genius simplified mapper + */ + +#include "mapinc.h" + +static uint8 latche; + +static SFORMAT StateRegs[] = +{ + { &latche, 1, "LATC" }, + { 0 } +}; + +static void Sync(void) { + setprg32(0x8000, latche >> 4); + setchr8(latche & 0xf); +} + +static DECLFW(M36Write) { + latche = V; + Sync(); +} + +static DECLFR(M36Read) { + return latche; // Need by Strike Wolf, being simplified mapper, this cart still uses some TCX mapper features andrely on it +} + +static void M36Power(void) { + latche = 0; + Sync(); + SetReadHandler(0x4100, 0x4100, M36Read); + SetReadHandler(0x8000, 0xFFFF, CartBR); + SetWriteHandler(0x8000, 0xFFFE, M36Write); // Actually, BUS conflict there preventing from triggering the wrong banks +} + +static void M36Restore(int version) { + Sync(); +} + +void Mapper36_Init(CartInfo *info) { + info->Power = M36Power; + GameStateRestore = M36Restore; + AddExState(StateRegs, ~0, 0, 0); +} diff --git a/src/boards/40.cpp b/src/boards/40.cpp new file mode 100644 index 00000000..3400200c --- /dev/null +++ b/src/boards/40.cpp @@ -0,0 +1,85 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2012 CaH4e3 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * FDS Conversion + * + */ + +#include "mapinc.h" + +static uint8 reg; +static uint32 IRQCount, IRQa; + +static SFORMAT StateRegs[] = +{ + { &IRQCount, 4, "IRQC" }, + { &IRQa, 4, "IRQA" }, + { ®, 1, "REG" }, + { 0 } +}; + +static void Sync(void) { + setprg8(0x6000, ~1); + setprg8(0x8000, ~3); + setprg8(0xa000, ~2); + setprg8(0xc000, reg); + setprg8(0xe000, ~0); + setchr8(0); +} + +static DECLFW(M40Write) { + switch (A & 0xe000) { + case 0x8000: IRQa = 0; IRQCount = 0; X6502_IRQEnd(FCEU_IQEXT); break; + case 0xa000: IRQa = 1; break; + case 0xe000: reg = V & 7; Sync(); break; + } +} + +static void M40Power(void) { + reg = 0; + Sync(); + SetReadHandler(0x6000, 0xffff, CartBR); + SetWriteHandler(0x8000, 0xffff, M40Write); +} + +static void M40Reset(void) { +} + +static void M40IRQHook(int a) { + if (IRQa) { + if (IRQCount < 4096) + IRQCount += a; + else{ + IRQa = 0; + X6502_IRQBegin(FCEU_IQEXT); + } + } +} + +static void StateRestore(int version) { + Sync(); +} + +void Mapper40_Init(CartInfo *info) { + info->Reset = M40Reset; + info->Power = M40Power; + MapIRQHook = M40IRQHook; + GameStateRestore = StateRestore; + AddExState(&StateRegs, ~0, 0, 0); +} diff --git a/src/boards/41.cpp b/src/boards/41.cpp new file mode 100644 index 00000000..d0d90839 --- /dev/null +++ b/src/boards/41.cpp @@ -0,0 +1,69 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2012 CaH4e3 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "mapinc.h" + +static uint8 mainreg, chrreg, mirror; + +static SFORMAT StateRegs[] = +{ + { &mainreg, 1, "MREG" }, + { &chrreg, 1, "CREG" }, + { &mirror, 1, "MIRR" }, + { 0 } +}; + +static void Sync(void) { + setprg32(0x8000, mainreg & 7); + setchr8(chrreg); + setmirror(mirror); +} + +static DECLFW(M41Write0) { + mainreg = A & 0xFF; + mirror = ((A >> 5) & 1) ^ 1; + chrreg = (chrreg & 3) | ((A >> 1) & 0xC); + Sync(); +} + +static DECLFW(M41Write1) { + if (mainreg & 0x4) { + chrreg = (chrreg & 0xC) | (A & 3); + Sync(); + } +} + +static void M41Power(void) { + mainreg = chrreg = 0; + Sync(); + SetReadHandler(0x8000, 0xFFFF, CartBR); + SetWriteHandler(0x6000, 0x67FF, M41Write0); + SetWriteHandler(0x8000, 0xFFFF, M41Write1); +} + +static void StateRestore(int version) { + Sync(); +} + +void Mapper41_Init(CartInfo *info) { + info->Power = M41Power; + GameStateRestore = StateRestore; + AddExState(&StateRegs, ~0, 0, 0); +} diff --git a/src/boards/42.cpp b/src/boards/42.cpp new file mode 100644 index 00000000..6407bdda --- /dev/null +++ b/src/boards/42.cpp @@ -0,0 +1,83 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2012 CaH4e3 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * FDS Conversion + * + */ + +#include "mapinc.h" + +static uint8 preg, creg, mirr; +static uint32 IRQCount, IRQa; + +static SFORMAT StateRegs[] = +{ + { &preg, 1, "PREG" }, + { &creg, 1, "CREG" }, + { &mirr, 1, "MIRR" }, + { &IRQCount, 4, "IRQC" }, + { &IRQa, 4, "IRQA" }, + { 0 } +}; + +static void Sync(void) { + setprg8(0x6000, preg); + setprg32(0x8000, ~0); + setchr8(creg); + setmirror(mirr); +} + +static DECLFW(M42Write) { + switch (A & 0xE003) { + case 0x8000: creg = V; Sync(); break; + case 0xE000: preg = V & 0x0F; Sync(); break; + case 0xE001: mirr = ((V >> 3) & 1 ) ^ 1; Sync(); break; + case 0xE002: IRQa = V & 2; if (!IRQa) IRQCount = 0; X6502_IRQEnd(FCEU_IQEXT); break; + } +} + +static void M42Power(void) { + preg = 0; + mirr = 1; // Ai Senshi Nicol actually has fixed mirroring, but mapper forcing it's default value now + Sync(); + SetReadHandler(0x6000, 0xffff, CartBR); + SetWriteHandler(0x6000, 0xffff, M42Write); +} + +static void M42IRQHook(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 StateRestore(int version) { + Sync(); +} + +void Mapper42_Init(CartInfo *info) { + info->Power = M42Power; + MapIRQHook = M42IRQHook; + GameStateRestore = StateRestore; + AddExState(&StateRegs, ~0, 0, 0); +} diff --git a/src/boards/43.cpp b/src/boards/43.cpp index c862e4c4..c7202129 100644 --- a/src/boards/43.cpp +++ b/src/boards/43.cpp @@ -25,70 +25,61 @@ static uint8 reg; static uint32 IRQCount, IRQa; -static SFORMAT StateRegs[]= +static SFORMAT StateRegs[] = { - {&IRQCount, 4, "IRQC"}, - {&IRQa, 1, "IRQA"}, - {®, 1, "REG"}, - {0} + { &IRQCount, 4, "IRQC" }, + { &IRQa, 4, "IRQA" }, + { ®, 1, "REG" }, + { 0 } }; -static void Sync(void) -{ - setprg4(0x5000,16); // Only YS-612 advdnced version - setprg8(0x6000,2); - setprg8(0x8000,1); - setprg8(0xa000,0); - setprg8(0xc000,reg); - setprg8(0xe000,9); - setchr8(0); +static void Sync(void) { + setprg4(0x5000, 16); // Only YS-612 advdnced version + setprg8(0x6000, 2); + setprg8(0x8000, 1); + setprg8(0xa000, 0); + setprg8(0xc000, reg); + setprg8(0xe000, 9); + setchr8(0); } -static DECLFW(M43Write) -{ -// int transo[8]={4,3,4,4,4,7,5,6}; - int transo[8]={4,3,5,3,6,3,7,3}; // According to hardware tests - switch(A&0xf1ff) - { - case 0x4022: reg=transo[V&7]; Sync(); break; - case 0x8122: // hacked version - case 0x4122: IRQa=V&1; X6502_IRQEnd(FCEU_IQEXT); IRQCount=0; break; // original version - } +static DECLFW(M43Write) { +// int transo[8]={4,3,4,4,4,7,5,6}; + int transo[8] = { 4, 3, 5, 3, 6, 3, 7, 3 }; // According to hardware tests + switch (A & 0xf1ff) { + case 0x4022: reg = transo[V & 7]; Sync(); break; + case 0x8122: // hacked version + case 0x4122: IRQa = V & 1; X6502_IRQEnd(FCEU_IQEXT); IRQCount = 0; break; // original version + } } -static void M43Power(void) -{ - reg=0; - Sync(); - SetReadHandler(0x5000,0xffff,CartBR); - SetWriteHandler(0x4020,0xffff,M43Write); +static void M43Power(void) { + reg = 0; + Sync(); + SetReadHandler(0x5000, 0xffff, CartBR); + SetWriteHandler(0x4020, 0xffff, M43Write); } -static void M43Reset(void) -{ +static void M43Reset(void) { } -static void M43IRQHook(int a) -{ - IRQCount+=a; - if(IRQa) - if(IRQCount>=4096) - { - IRQa=0; - X6502_IRQBegin(FCEU_IQEXT); - } +static void M43IRQHook(int a) { + IRQCount += a; + if (IRQa) + if (IRQCount >= 4096) { + IRQa = 0; + X6502_IRQBegin(FCEU_IQEXT); + } } -static void StateRestore(int version) -{ - Sync(); +static void StateRestore(int version) { + Sync(); } -void Mapper43_Init(CartInfo *info) -{ - info->Reset=M43Reset; - info->Power=M43Power; - MapIRQHook=M43IRQHook; - GameStateRestore=StateRestore; - AddExState(&StateRegs, ~0, 0, 0); +void Mapper43_Init(CartInfo *info) { + info->Reset = M43Reset; + info->Power = M43Power; + MapIRQHook = M43IRQHook; + GameStateRestore = StateRestore; + AddExState(&StateRegs, ~0, 0, 0); } diff --git a/src/mappers/50.cpp b/src/boards/46.cpp similarity index 50% rename from src/mappers/50.cpp rename to src/boards/46.cpp index 629d86d3..04e03122 100644 --- a/src/mappers/50.cpp +++ b/src/boards/46.cpp @@ -1,7 +1,7 @@ /* FCE Ultra - NES/Famicom Emulator * * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel + * Copyright (C) 2012 CaH4e3 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,56 +20,50 @@ #include "mapinc.h" +static uint8 reg0, reg1; -static void Mapper50IRQ(int a) +static SFORMAT StateRegs[] = { - if(IRQa) - { - if(IRQCount<4096) - IRQCount+=a; - else - { - IRQa=0; - X6502_IRQBegin(FCEU_IQEXT); - } - } + { ®0, 1, "REG0" }, + { ®1, 1, "REG1" }, + { 0 } +}; + +static void Sync(void) { + setprg32(0x8000, (reg1 & 1) + ((reg0 & 0xF) << 1)); + setchr8(((reg1 >> 4) & 7) + ((reg0 & 0xF0) >> 1)); } -static void M50Restore(int version) -{ - setprg8(0xc000,mapbyte1[0]); +static DECLFW(M46Write0) { + reg0 = V; + Sync(); } -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); - } - } +static DECLFW(M46Write1) { + reg1 = V; + Sync(); } -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); +static void M46Power(void) { + reg0 = reg1 = 0; + Sync(); + SetReadHandler(0x8000, 0xFFFF, CartBR); + SetWriteHandler(0x6000, 0x7FFF, M46Write0); + SetWriteHandler(0x8000, 0xFFFF, M46Write1); } +static void M46Reset(void) { + reg0 = reg1 = 0; + Sync(); +} + +static void StateRestore(int version) { + Sync(); +} + +void Mapper46_Init(CartInfo *info) { + info->Power = M46Power; + info->Reset = M46Reset; + GameStateRestore = StateRestore; + AddExState(&StateRegs, ~0, 0, 0); +} diff --git a/src/boards/50.cpp b/src/boards/50.cpp new file mode 100644 index 00000000..a9ce08d3 --- /dev/null +++ b/src/boards/50.cpp @@ -0,0 +1,84 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2012 CaH4e3 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * FDS Conversion + * + */ + +#include "mapinc.h" + +static uint8 reg; +static uint32 IRQCount, IRQa; + +static SFORMAT StateRegs[] = +{ + { &IRQCount, 4, "IRQC" }, + { &IRQa, 4, "IRQA" }, + { ®, 1, "REG" }, + { 0 } +}; + +static void Sync(void) { + setprg8(0x6000, 0xF); + setprg8(0x8000, 0x8); + setprg8(0xa000, 0x9); + setprg8(0xc000, reg); + setprg8(0xe000, 0xB); + setchr8(0); +} + +static DECLFW(M50Write) { + switch (A & 0xD160) { + case 0x4120: IRQa = V & 1; if (!IRQa) IRQCount = 0; X6502_IRQEnd(FCEU_IQEXT); break; + case 0x4020: reg = ((V & 1) << 2) | ((V & 2) >> 1) | ((V & 4) >> 1) | (V & 8); Sync(); break; + } +} + +static void M50Power(void) { + reg = 0; + Sync(); + SetReadHandler(0x6000, 0xffff, CartBR); + SetWriteHandler(0x4020, 0x5fff, M50Write); +} + +static void M50Reset(void) { +} + +static void M50IRQHook(int a) { + if (IRQa) { + if (IRQCount < 4096) + IRQCount += a; + else{ + IRQa = 0; + X6502_IRQBegin(FCEU_IQEXT); + } + } +} + +static void StateRestore(int version) { + Sync(); +} + +void Mapper50_Init(CartInfo *info) { + info->Reset = M50Reset; + info->Power = M50Power; + MapIRQHook = M50IRQHook; + GameStateRestore = StateRestore; + AddExState(&StateRegs, ~0, 0, 0); +} diff --git a/src/boards/51.cpp b/src/boards/51.cpp new file mode 100644 index 00000000..02d693c3 --- /dev/null +++ b/src/boards/51.cpp @@ -0,0 +1,84 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2012 CaH4e3 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "mapinc.h" + +static uint8 bank, mode; +static SFORMAT StateRegs[] = +{ + { &bank, 1, "BANK" }, + { &mode, 1, "MODE" }, + { 0 } +}; + +static void Sync(void) { + if (mode & 2) { + setprg8(0x6000, ((bank & 7) << 2) | 0x23); + setprg16(0x8000, (bank << 1) | 0); + setprg16(0xC000, (bank << 1) | 1); + } else { + setprg8(0x6000, ((bank & 4) << 2) | 0x2F); + setprg16(0x8000, (bank << 1) | (mode >> 4)); + setprg16(0xC000, ((bank & 0xC) << 1) | 7); + } + if (mode == 0x12) + setmirror(MI_H); + else + setmirror(MI_V); + setchr8(0); +} + +static DECLFW(M51WriteMode) { + mode = V & 0x12; + Sync(); +} + +static DECLFW(M51WriteBank) { + bank = V & 0x0F; + if (A & 0x4000) + mode = (mode & 2) | (V & 0x10); + Sync(); +} + +static void M51Power(void) { + bank = 0; + mode = 2; + Sync(); + SetWriteHandler(0x6000, 0x7FFF, M51WriteMode); + SetWriteHandler(0x8000, 0xFFFF, M51WriteBank); + SetReadHandler(0x6000, 0xFFFF, CartBR); +} + +static void M51Reset(void) { + bank = 0; + mode = 2; + Sync(); +} + +static void StateRestore(int version) { + Sync(); +} + +void Mapper51_Init(CartInfo *info) { + info->Power = M51Power; + info->Reset = M51Reset; + AddExState(&StateRegs, ~0, 0, 0); + GameStateRestore = StateRestore; +} diff --git a/src/boards/62.cpp b/src/boards/62.cpp new file mode 100644 index 00000000..0dc2a63d --- /dev/null +++ b/src/boards/62.cpp @@ -0,0 +1,69 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2012 CaH4e3 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "mapinc.h" + +static uint8 bank; +static uint16 mode; +static SFORMAT StateRegs[] = +{ + { &bank, 1, "BANK" }, + { &mode, 2, "MODE" }, + { 0 } +}; + +static void Sync(void) { + setchr8(((mode & 0x1F) << 2) | (bank & 0x03)); + if (mode & 0x20) { + setprg16(0x8000, (mode & 0x40) | ((mode >> 8) & 0x3F)); + setprg16(0xc000, (mode & 0x40) | ((mode >> 8) & 0x3F)); + } else + setprg32(0x8000, ((mode & 0x40) | ((mode >> 8) & 0x3F)) >> 1); + setmirror(((mode >> 7) & 1) ^ 1); +} + +static DECLFW(M62Write) { + mode = A & 0x3FFF; + bank = V & 3; + Sync(); +} + +static void M62Power(void) { + bank = mode = 0; + Sync(); + SetWriteHandler(0x8000, 0xFFFF, M62Write); + SetReadHandler(0x8000, 0xFFFF, CartBR); +} + +static void M62Reset(void) { + bank = mode = 0; + Sync(); +} + +static void StateRestore(int version) { + Sync(); +} + +void Mapper62_Init(CartInfo *info) { + info->Power = M62Power; + info->Reset = M62Reset; + AddExState(&StateRegs, ~0, 0, 0); + GameStateRestore = StateRestore; +} diff --git a/src/boards/71.cpp b/src/boards/71.cpp new file mode 100644 index 00000000..37c05aab --- /dev/null +++ b/src/boards/71.cpp @@ -0,0 +1,64 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2012 CaH4e3 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "mapinc.h" + +static uint8 preg, mirr; + +static SFORMAT StateRegs[] = +{ + { &preg, 1, "PREG" }, + { &mirr, 1, "MIRR" }, + { 0 } +}; + +static void Sync(void) { + setprg16(0x8000, preg); + setprg16(0xC000, ~0); + setchr8(0); + if(mirr) + setmirror(mirr); +} + +static DECLFW(M71Write) { + if ((A & 0xF000) == 0x9000) + mirr = MI_0 + ((V >> 4) & 1); // 2-in-1, some carts are normal hardwire V/H mirror, some uses mapper selectable 0/1 mirror + else + preg = V; + Sync(); +} + +static void M71Power(void) { + mirr = 0; + Sync(); + SetReadHandler(0x8000, 0xFFFF, CartBR); + SetWriteHandler(0x8000, 0xFFFF, M71Write); +} + +static void StateRestore(int version) { + Sync(); +} + +void Mapper71_Init(CartInfo *info) { + info->Power = M71Power; + GameStateRestore = StateRestore; + + AddExState(&StateRegs, ~0, 0, 0); +} diff --git a/src/mappers/51.cpp b/src/boards/72.cpp similarity index 50% rename from src/mappers/51.cpp rename to src/boards/72.cpp index 5c618048..de5ec91d 100644 --- a/src/mappers/51.cpp +++ b/src/boards/72.cpp @@ -1,66 +1,64 @@ -/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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(); -} +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2012 CaH4e3 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Moero!! Pro Tennis have ADPCM codec on-board, PROM isn't dumped, emulation isn't + * possible just now. + */ + +#include "mapinc.h" + +static uint8 preg, creg; + +static SFORMAT StateRegs[] = +{ + { &preg, 1, "PREG" }, + { &creg, 1, "CREG" }, + { 0 } +}; + +static void Sync(void) { + setprg16(0x8000, preg); + setprg16(0xC000, ~0); + setchr8(creg); +} + +static DECLFW(M72Write) { + if (V & 0x80) + preg = V & 0xF; + if (V & 0x40) + creg = V & 0xF; + Sync(); +} + +static void M72Power(void) { + Sync(); + SetReadHandler(0x8000, 0xFFFF, CartBR); + SetWriteHandler(0x6000, 0xFFFF, M72Write); +} + +static void StateRestore(int version) { + Sync(); +} + +void Mapper72_Init(CartInfo *info) { + info->Power = M72Power; + GameStateRestore = StateRestore; + + AddExState(&StateRegs, ~0, 0, 0); +} diff --git a/src/boards/77.cpp b/src/boards/77.cpp new file mode 100644 index 00000000..bbba3e8f --- /dev/null +++ b/src/boards/77.cpp @@ -0,0 +1,75 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2012 CaH4e3 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "mapinc.h" + +static uint8 latche; + +static uint8 *CHRRAM=NULL; +static uint32 CHRRAMSIZE; + +static SFORMAT StateRegs[] = +{ + { &latche, 1, "LATC" }, + { 0 } +}; + +static void Sync(void) { + setprg32(0x8000, latche & 7); + setchr2(0x0000, latche >> 4); + setchr2r(0x10, 0x0800, 2); + setchr4r(0x10, 0x1000, 0); +} + +static DECLFW(M77Write) { + latche = V; + Sync(); +} + +static void M77Power(void) { + latche = 0; + Sync(); + SetReadHandler(0x8000, 0xFFFF, CartBR); + SetWriteHandler(0x8000, 0xFFFF, M77Write); +} + +static void M77Close(void) +{ + if (CHRRAM) + FCEU_gfree(CHRRAM); + CHRRAM = NULL; +} + +static void StateRestore(int version) { + Sync(); +} + +void Mapper77_Init(CartInfo *info) { + info->Power = M77Power; + info->Close = M77Close; + GameStateRestore = StateRestore; + + CHRRAMSIZE = 6 * 1024; + CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); + SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); + AddExState(CHRRAM, CHRRAMSIZE, 0, "CRAM"); + + AddExState(&StateRegs, ~0, 0, 0); +} diff --git a/src/mappers/77.cpp b/src/boards/79.cpp similarity index 52% rename from src/mappers/77.cpp rename to src/boards/79.cpp index fb9fd84f..0aa35e21 100644 --- a/src/mappers/77.cpp +++ b/src/boards/79.cpp @@ -1,54 +1,60 @@ -/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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; -} +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2012 CaH4e3 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "mapinc.h" + +static uint8 creg, preg; +static SFORMAT StateRegs[] = +{ + { &creg, 1, "CREG" }, + { &preg, 1, "PREG" }, + { 0 } +}; + +static void Sync(void) { + setprg32(0x8000, preg); + setchr8(creg); +} + +static DECLFW(M79Write) { + if ((A < 0x8000) && ((A ^ 0x4100) == 0)) { + preg = (V >> 3) & 1; + } + creg = V & 7; + Sync(); +} + +static void M79Power(void) { + preg = ~0; + Sync(); + SetWriteHandler(0x4100, 0x5FFF, M79Write); + SetWriteHandler(0x8000, 0xFFFF, M79Write); + SetReadHandler(0x8000, 0xFFFF, CartBR); +} + +static void StateRestore(int version) { + Sync(); +} + +void Mapper79_Init(CartInfo *info) { + info->Power = M79Power; + AddExState(&StateRegs, ~0, 0, 0); + GameStateRestore = StateRestore; +} diff --git a/src/boards/80.cpp b/src/boards/80.cpp new file mode 100644 index 00000000..f6f4ebe6 --- /dev/null +++ b/src/boards/80.cpp @@ -0,0 +1,192 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2012 CaH4e3 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "mapinc.h" + +static uint8 preg[3], creg[6], isExMirr; +static uint8 mirr, cmd, wram_enable, wram[256]; +static uint8 mcache[8]; +static uint32 lastppu; + +static SFORMAT StateRegs80[] = +{ + { preg, 3, "PREG" }, + { creg, 6, "CREG" }, + { wram, 256, "WRAM" }, + { &mirr, 1, "MIRR" }, + { &wram_enable, 1, "WRME" }, + { 0 } +}; + +static SFORMAT StateRegs95[] = +{ + { &cmd, 1, "CMDR" }, + { preg, 3, "PREG" }, + { creg, 6, "CREG" }, + { mcache, 8, "MCCH" }, + { &lastppu, 4, "LPPU" }, + { 0 } +}; + +static SFORMAT StateRegs207[] = +{ + { preg, 3, "PREG" }, + { creg, 6, "CREG" }, + { mcache, 8, "MCCH" }, + { &lastppu, 4, "LPPU" }, + { 0 } +}; + +static void Sync(void) { + setprg8(0x8000, preg[0]); + setprg8(0xA000, preg[1]); + setprg8(0xC000, preg[2]); + setprg8(0xE000, ~0); + setchr2(0x0000, (creg[0] >> 1) & 0x3F); + setchr2(0x0800, (creg[1] >> 1) & 0x3F); + setchr1(0x1000, creg[2]); + setchr1(0x1400, creg[3]); + setchr1(0x1800, creg[4]); + setchr1(0x1C00, creg[5]); + if (isExMirr) { + setmirror(MI_0 + mcache[lastppu]); + } else + setmirror(mirr); +} + +static DECLFW(M80RamWrite) { + if(wram_enable == 0xA3) + wram[A & 0xFF] = V; +} + +static DECLFR(M80RamRead) { + if(wram_enable == 0xA3) + return wram[A & 0xFF]; + else + return 0xFF; +} + +static DECLFW(M80Write) { + switch (A) { + case 0x7EF0: creg[0] = V; mcache[0] = mcache[1] = V >> 7; Sync(); break; + case 0x7EF1: creg[1] = V; mcache[2] = mcache[3] = V >> 7; Sync(); break; + case 0x7EF2: creg[2] = V; mcache[4] = V >> 7; Sync(); break; + case 0x7EF3: creg[3] = V; mcache[5] = V >> 7; Sync(); break; + case 0x7EF4: creg[4] = V; mcache[6] = V >> 7; Sync(); break; + case 0x7EF5: creg[5] = V; mcache[7] = V >> 7; Sync(); break; + case 0x7EF6: mirr = V & 1; Sync(); break; + case 0x7EF8: wram_enable = V; break; + case 0x7EFA: + case 0x7EFB: preg[0] = V; Sync(); break; + case 0x7EFC: + case 0x7EFD: preg[1] = V; Sync(); break; + case 0x7EFE: + case 0x7EFF: preg[2] = V; Sync(); break; + } +} + +static DECLFW(M95Write) { + switch (A & 0xF001) { + case 0x8000: cmd = V; break; + case 0x8001: + switch (cmd & 0x07) { + case 0: creg[0] = V & 0x1F; mcache[0] = mcache[1] = (V >> 5) & 1; Sync(); break; + case 1: creg[1] = V & 0x1F; mcache[2] = mcache[3] = (V >> 5) & 1; Sync(); break; + case 2: creg[2] = V & 0x1F; mcache[4] = (V >> 5) & 1; Sync(); break; + case 3: creg[3] = V & 0x1F; mcache[5] = (V >> 5) & 1; Sync(); break; + case 4: creg[4] = V & 0x1F; mcache[6] = (V >> 5) & 1; Sync(); break; + case 5: creg[5] = V & 0x1F; mcache[7] = (V >> 5) & 1; Sync(); break; + case 6: preg[0] = V; Sync(); break; + case 7: preg[1] = V; Sync(); break; + } + Sync(); + } +} + +static void MExMirrPPU(uint32 A) { + static int8 lastmirr = -1, curmirr; + if (A < 0x2000) { + lastppu = A >> 10; + curmirr = mcache[lastppu]; + if (curmirr != lastmirr) { + setmirror(MI_0 + curmirr); + lastmirr = curmirr; + } + } +} + +static void M80Power(void) { + wram_enable = 0xFF; + Sync(); + SetReadHandler(0x7F00, 0x7FFF, M80RamRead); + SetWriteHandler(0x7F00, 0x7FFF, M80RamWrite); + SetWriteHandler(0x7EF0, 0x7EFF, M80Write); + SetReadHandler(0x8000, 0xFFFF, CartBR); +} + +static void M207Power(void) { + mcache[0] = mcache[1] = mcache[2] = mcache[3] = 0; + mcache[4] = mcache[5] = mcache[6] = mcache[7] = 0; + Sync(); + SetWriteHandler(0x7EF0, 0x7EFF, M80Write); + SetReadHandler(0x8000, 0xFFFF, CartBR); +} + +static void M95Power(void) { + preg[2] = ~1; + mcache[0] = mcache[1] = mcache[2] = mcache[3] = 0; + mcache[4] = mcache[5] = mcache[6] = mcache[7] = 0; + Sync(); + SetWriteHandler(0x8000, 0xFFFF, M95Write); + SetReadHandler(0x8000, 0xFFFF, CartBR); +} + +static void StateRestore(int version) { + Sync(); +} + +void Mapper80_Init(CartInfo *info) { + isExMirr = 0; + info->Power = M80Power; + GameStateRestore = StateRestore; + + if (info->battery) { + info->SaveGame[0] = wram; + info->SaveGameLen[0] = 256; + } + + AddExState(&StateRegs80, ~0, 0, 0); +} + +void Mapper95_Init(CartInfo *info) { + isExMirr = 1; + info->Power = M95Power; + PPU_hook = MExMirrPPU; + GameStateRestore = StateRestore; + AddExState(&StateRegs95, ~0, 0, 0); +} + +void Mapper207_Init(CartInfo *info) { + isExMirr = 1; + info->Power = M207Power; + PPU_hook = MExMirrPPU; + GameStateRestore = StateRestore; + AddExState(&StateRegs207, ~0, 0, 0); +} diff --git a/src/boards/88.cpp b/src/boards/88.cpp index f9b544c1..c9ac31e5 100644 --- a/src/boards/88.cpp +++ b/src/boards/88.cpp @@ -23,65 +23,58 @@ static uint8 reg[8]; static uint8 mirror, cmd, is154; -static SFORMAT StateRegs[]= +static SFORMAT StateRegs[] = { - {&cmd, 1, "CMD"}, - {&mirror, 1, "MIRR"}, - {reg, 8, "REGS"}, - {0} + { &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 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]); + setprg8(0xC000, ~1); + setprg8(0xE000, ~0); } -static void MSync(void) -{ - if(is154)setmirror(MI_0+(mirror&1)); +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 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 M88Power(void) { + SetReadHandler(0x8000, 0xFFFF, CartBR); + SetWriteHandler(0x8000, 0xFFFF, M88Write); } -static void StateRestore(int version) -{ - Sync(); - MSync(); +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 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); +void Mapper154_Init(CartInfo *info) { + is154 = 1; + info->Power = M88Power; + GameStateRestore = StateRestore; + AddExState(&StateRegs, ~0, 0, 0); } diff --git a/src/boards/95.cpp b/src/boards/95.cpp deleted file mode 100644 index 0a5d9dd6..00000000 --- a/src/boards/95.cpp +++ /dev/null @@ -1,125 +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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" -#include "../ines.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 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/src/boards/SConscript b/src/boards/SConscript index 0cc186a8..d072b8b0 100644 --- a/src/boards/SConscript +++ b/src/boards/SConscript @@ -29,6 +29,7 @@ my_list = Split(""" 189.cpp 193.cpp 199.cpp +206.cpp 208.cpp 222.cpp 225.cpp @@ -45,12 +46,25 @@ my_list = Split(""" 32.cpp 33.cpp 34.cpp +36.cpp 3d-block.cpp +40.cpp +41.cpp 411120-c.cpp +42.cpp 43.cpp +46.cpp +50.cpp +51.cpp 57.cpp 603-5052.cpp +62.cpp 68.cpp +71.cpp +72.cpp +77.cpp +79.cpp +80.cpp 8157.cpp 82.cpp 8237.cpp @@ -58,7 +72,6 @@ my_list = Split(""" 88.cpp 90.cpp 91.cpp -95.cpp 96.cpp 99.cpp a9711.cpp @@ -124,7 +137,9 @@ t-262.cpp tengen.cpp tf-1201.cpp transformer.cpp +vrc1.cpp vrc2and4.cpp +vrc3.cpp vrc7.cpp yoko.cpp """) diff --git a/src/boards/__dummy_mapper.cpp b/src/boards/__dummy_mapper.cpp index 48f527b1..c9fa8a96 100644 --- a/src/boards/__dummy_mapper.cpp +++ b/src/boards/__dummy_mapper.cpp @@ -46,8 +46,8 @@ static DECLFW(MNNNWrite) { } static void MNNNPower(void) { -// SetReadHandler(0x6000,0x7fff,CartBR); -// SetWriteHandler(0x6000,0x7fff,CartBW); +// SetReadHandler(0x6000, 0x7fff, CartBR); +// SetWriteHandler(0x6000, 0x7fff, CartBW); SetReadHandler(0x8000, 0xFFFF, CartBR); SetWriteHandler(0x8000, 0xFFFF, MNNNWrite); } diff --git a/src/boards/addrlatch.cpp b/src/boards/addrlatch.cpp index 319676ed..ae463002 100644 --- a/src/boards/addrlatch.cpp +++ b/src/boards/addrlatch.cpp @@ -173,7 +173,7 @@ void BMCGK192_Init(CartInfo *info) { } //------------------ Map 059 --------------------------- -// One more forbidden mapper +// One more forgotten mapper static void M59Sync(void) { setprg32(0x8000, (latche >> 4) & 7); setchr8(latche & 0x7); @@ -191,6 +191,21 @@ void Mapper59_Init(CartInfo *info) { Latch_Init(info, M59Sync, M59Read, 0x0000, 0x8000, 0xFFFF, 0); } +//------------------ Map 061 --------------------------- +static void M61Sync(void) { + if (((latche & 0x10) << 1) ^ (latche & 0x20)) { + setprg16(0x8000, ((latche & 0xF) << 1) | (((latche & 0x20) >> 4))); + setprg16(0xC000, ((latche & 0xF) << 1) | (((latche & 0x20) >> 4))); + } else + setprg32(0x8000, latche & 0xF); + setchr8(0); + setmirror(((latche >> 7) & 1) ^ 1); +} + +void Mapper61_Init(CartInfo *info) { + Latch_Init(info, M61Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0); +} + //------------------ Map 092 --------------------------- // Another two-in-one mapper, two Jaleco carts uses similar // hardware, but with different wiring. diff --git a/src/boards/datalatch.cpp b/src/boards/datalatch.cpp index 5b2c5b75..7f39add0 100644 --- a/src/boards/datalatch.cpp +++ b/src/boards/datalatch.cpp @@ -153,7 +153,7 @@ void CNROM_Init(CartInfo *info) { //------------------ Map 7 --------------------------- static void ANROMSync() { - setprg32(0x8000, latche & 0xf); + setprg32(0x8000, latche & 0xF); setmirror(MI_0 + ((latche >> 4) & 1)); setchr8(0); } @@ -177,7 +177,7 @@ void Mapper8_Init(CartInfo *info) { //------------------ Map 11 --------------------------- static void M11Sync(void) { - setprg32(0x8000, latche & 0xf); + setprg32(0x8000, latche & 0xF); setchr8(latche >> 4); } @@ -201,17 +201,6 @@ void CPROM_Init(CartInfo *info) { Latch_Init(info, CPROMSync, 0, 0x8000, 0xFFFF, 0, 0); } -//------------------ Map 36 --------------------------- - -static void M36Sync(void) { - setprg32(0x8000, latche >> 4); - setchr8((latche) & 0xF); -} - -void Mapper36_Init(CartInfo *info) { - Latch_Init(info, M36Sync, 0, 0x8400, 0xfffe, 0, 0); -} - //------------------ Map 38 --------------------------- static void M38Sync(void) { @@ -228,7 +217,7 @@ void Mapper38_Init(CartInfo *info) { static void MHROMSync(void) { setprg32(0x8000, latche >> 4); - setchr8(latche & 0xf); + setchr8(latche & 0xF); } void MHROM_Init(CartInfo *info) { @@ -432,7 +421,7 @@ void Mapper203_Init(CartInfo *info) { static void M240Sync(void) { setprg8r(0x10, 0x6000, 0); setprg32(0x8000, latche >> 4); - setchr8(latche & 0xf); + setchr8(latche & 0xF); } void Mapper240_Init(CartInfo *info) { diff --git a/src/boards/deirom.cpp b/src/boards/deirom.cpp deleted file mode 100644 index 2d28bd00..00000000 --- a/src/boards/deirom.cpp +++ /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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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) -{ - int x; - setchr2(0x0000,DRegs[0]); - setchr2(0x0800,DRegs[1]); - 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/src/boards/mmc3.cpp b/src/boards/mmc3.cpp index 6b93ce78..0b0c4d5b 100644 --- a/src/boards/mmc3.cpp +++ b/src/boards/mmc3.cpp @@ -33,30 +33,30 @@ uint8 *CHRRAM; uint32 CHRRAMSize; uint8 DRegBuf[8]; uint8 EXPREGS[8]; /* For bootleg games, mostly. */ -uint8 A000B,A001B; -uint8 mmc3opts=0; +uint8 A000B, A001B; +uint8 mmc3opts = 0; #undef IRQCount #undef IRQLatch #undef IRQa -uint8 IRQCount,IRQLatch,IRQa; +uint8 IRQCount, IRQLatch, IRQa; uint8 IRQReload; -static SFORMAT MMC3_StateRegs[]= +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} + { 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 wrams; -static int isRevB=1; +static int isRevB = 1; void (*pwrap)(uint32 A, uint8 V); void (*cwrap)(uint32 A, uint8 V); @@ -72,277 +72,248 @@ 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); +void FixMMC3PRG(int V) { + if (V & 0x40) { + pwrap(0xC000, DRegBuf[6]); + pwrap(0x8000, ~1); + } else { + pwrap(0x8000, DRegBuf[6]); + pwrap(0xC000, ~1); } - else - { - pwrap(0x8000,DRegBuf[6]); - pwrap(0xC000,~1); - } - pwrap(0xA000,DRegBuf[7]); - pwrap(0xE000,~0); + pwrap(0xA000, DRegBuf[7]); + pwrap(0xE000, ~0); } -void FixMMC3CHR(int V) -{ - int cbase=(V&0x80)<<5; +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 ^ 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]); + cwrap(cbase ^ 0x1000, DRegBuf[2]); + cwrap(cbase ^ 0x1400, DRegBuf[3]); + cwrap(cbase ^ 0x1800, DRegBuf[4]); + cwrap(cbase ^ 0x1c00, DRegBuf[5]); - if(mwrap) mwrap(A000B); + if (mwrap) mwrap(A000B); } -void MMC3RegReset(void) -{ - IRQCount=IRQLatch=IRQa=MMC3_cmd=0; +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; + 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); + FixMMC3PRG(0); + FixMMC3CHR(0); } -DECLFW(MMC3_CMDWrite) -{ -// FCEU_printf("bs %04x %02x\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); - break; - case 0xA001: - A001B=V; - break; - } +DECLFW(MMC3_CMDWrite) { +// FCEU_printf("bs %04x %02x\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); + break; + case 0xA001: + A001B = V; + 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; - } +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 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(void) { + ClockMMC3Counter(); } -static void MMC3_hb_KickMasterHack(void) -{ - if(scanline==238) ClockMMC3Counter(); - ClockMMC3Counter(); +static void MMC3_hb_KickMasterHack(void) { + if (scanline == 238) ClockMMC3Counter(); + ClockMMC3Counter(); } -static void MMC3_hb_PALStarWarsHack(void) -{ - if(scanline==240) ClockMMC3Counter(); - ClockMMC3Counter(); +static void MMC3_hb_PALStarWarsHack(void) { + if (scanline == 240) ClockMMC3Counter(); + ClockMMC3Counter(); } -void GenMMC3Restore(int version) -{ - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); +void GenMMC3Restore(int version) { + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); } -static void GENCWRAP(uint32 A, uint8 V) -{ - setchr1(A,V); // Business Wars NEEDS THIS for 8K CHR-RAM +static void GENCWRAP(uint32 A, uint8 V) { + setchr1(A, V); // Business Wars NEEDS THIS for 8K CHR-RAM } -static void GENPWRAP(uint32 A, uint8 V) -{ - setprg8(A,V&0x7F); // [NJ102] Mo Dao Jie (C) has 1024Mb MMC3 BOARD, maybe something other will be broken +static void GENPWRAP(uint32 A, uint8 V) { + setprg8(A, V & 0x7F); // [NJ102] Mo Dao Jie (C) has 1024Mb MMC3 BOARD, maybe something other will be broken } -static void GENMWRAP(uint8 V) -{ - A000B=V; - setmirror((V&1)^1); +static void GENMWRAP(uint8 V) { + A000B = V; + setmirror((V & 1) ^ 1); } -static void GENNOMWRAP(uint8 V) -{ - A000B=V; +static void GENNOMWRAP(uint8 V) { + A000B = V; } -static DECLFW(MBWRAMMMC6) -{ - WRAM[A&0x3ff]=V; +static DECLFW(MBWRAMMMC6) { + WRAM[A & 0x3ff] = V; } -static DECLFR(MAWRAMMMC6) -{ - return(WRAM[A&0x3ff]); +static DECLFR(MAWRAMMMC6) { + return(WRAM[A & 0x3ff]); } -void GenMMC3Power(void) -{ - if(UNIFchrrama) setchr8(0); +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&0x1fff)>>10,0x6000,WRAM); - SetWriteHandler(0x6000,0x6000 + ((wrams - 1) & 0x1fff),CartBW); - SetReadHandler(0x6000,0x6000 + ((wrams - 1) & 0x1fff),CartBR); - setprg8r(0x10,0x6000,0); - } - if(!(mmc3opts&2)) - FCEU_dwmemset(WRAM,0,wrams); - } - MMC3RegReset(); - if(CHRRAM) - FCEU_dwmemset(CHRRAM,0,CHRRAMSize); + 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 & 0x1fff) >> 10, 0x6000, WRAM); + SetWriteHandler(0x6000, 0x6000 + ((wrams - 1) & 0x1fff), CartBW); + SetReadHandler(0x6000, 0x6000 + ((wrams - 1) & 0x1fff), CartBR); + setprg8r(0x10, 0x6000, 0); + } + 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 void GenMMC3Close(void) { + if (CHRRAM) + FCEU_gfree(CHRRAM); + if (WRAM) + FCEU_gfree(WRAM); + CHRRAM = WRAM = NULL; } -void GenMMC3_Init(CartInfo *info, int prg, int chr, int wram, int battery) -{ - pwrap=GENPWRAP; - cwrap=GENCWRAP; - mwrap=GENMWRAP; +void GenMMC3_Init(CartInfo *info, int prg, int chr, int wram, int battery) { + pwrap = GENPWRAP; + cwrap = GENCWRAP; + mwrap = GENMWRAP; - wrams=wram<<10; + wrams = wram << 10; - PRGmask8[0]&=(prg>>13)-1; - CHRmask1[0]&=(chr>>10)-1; - CHRmask2[0]&=(chr>>11)-1; + PRGmask8[0] &= (prg >> 13) - 1; + CHRmask1[0] &= (chr >> 10) - 1; + CHRmask2[0] &= (chr >> 11) - 1; - if(wram) - { - mmc3opts|=1; - WRAM=(uint8*)FCEU_gmalloc(wrams); - SetupCartPRGMapping(0x10,WRAM,wrams,1); - AddExState(WRAM, wrams, 0, "MRAM"); - } + if (wram) { + mmc3opts |= 1; + WRAM = (uint8*)FCEU_gmalloc(wrams); + SetupCartPRGMapping(0x10, WRAM, wrams, 1); + AddExState(WRAM, wrams, 0, "MRAM"); + } - if(battery) - { - mmc3opts|=2; - info->SaveGame[0]=WRAM; - info->SaveGameLen[0]=wrams; - } + if (battery) { + mmc3opts |= 2; + info->SaveGame[0] = WRAM; + info->SaveGameLen[0] = wrams; + } - AddExState(MMC3_StateRegs, ~0, 0, 0); + AddExState(MMC3_StateRegs, ~0, 0, 0); - info->Power=GenMMC3Power; - info->Reset=MMC3RegReset; - info->Close=GenMMC3Close; + 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; - GameStateRestore=GenMMC3Restore; + 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; + GameStateRestore = GenMMC3Restore; } // ---------------------------------------------------------------------- @@ -351,516 +322,453 @@ void GenMMC3_Init(CartInfo *info, int prg, int chr, int wram, int battery) // ---------------------------- Mapper 4 -------------------------------- -static int hackm4=0;/* For Karnov, maybe others. BLAH. Stupid iNES format.*/ +static int hackm4 = 0; /* For Karnov, maybe others. BLAH. Stupid iNES format.*/ -static void M4Power(void) -{ - GenMMC3Power(); - A000B=(hackm4^1)&1; - setmirror(hackm4); +static void M4Power(void) { + GenMMC3Power(); + A000B = (hackm4 ^ 1) & 1; + setmirror(hackm4); } -void Mapper4_Init(CartInfo *info) -{ - int ws=8; +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; + 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 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 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); +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; - isRevB=0; +void Mapper12_Init(CartInfo *info) { + GenMMC3_Init(info, 512, 256, 8, info->battery); + cwrap = M12CW; + isRevB = 0; - info->Power=M12Power; - AddExState(EXPREGS, 2, 0, "EXPR"); + 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 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 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 DECLFW(M37Write) { + EXPREGS[0] = (V & 6) >> 1; + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); } -static void M37Reset(void) -{ - EXPREGS[0]=0; - MMC3RegReset(); +static void M37Reset(void) { + EXPREGS[0] = 0; + MMC3RegReset(); } -static void M37Power(void) -{ - EXPREGS[0]=0; - GenMMC3Power(); - SetWriteHandler(0x6000,0x7FFF,M37Write); +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"); +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 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 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 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); +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"); +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 - if(EXPREGS[2]) - NV&=0; // hack ;( don't know exactly how it should be - NV|=EXPREGS[0]|((EXPREGS[2]&0xF0)<<4); - setchr1(A,NV); - } +static void M45CW(uint32 A, uint8 V) { + if (!UNIFchrrama) { + uint32 NV = V; + if (EXPREGS[2] & 8) + NV &= (1 << ((EXPREGS[2] & 7) + 1)) - 1; + else + if (EXPREGS[2]) + NV &= 0; // hack ;( don't know exactly how it should be + 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 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 DECLFW(M45Write) { + if (EXPREGS[3] & 0x40) { + WRAM[A - 0x6000] = V; + return; + } + EXPREGS[EXPREGS[4]] = V; + EXPREGS[4] = (EXPREGS[4] + 1) & 3; + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); } -static DECLFR(M45Read) -{ - uint32 addr = 1<<(EXPREGS[5]+4); - if(A&(addr|(addr-1))) - return X.DB | 1; - else - return X.DB; +static DECLFR(M45Read) { + uint32 addr = 1 << (EXPREGS[5] + 4); + if (A & (addr | (addr - 1))) + return X.DB | 1; + else + return X.DB; } -static void M45Reset(void) -{ - EXPREGS[0]=EXPREGS[1]=EXPREGS[2]=EXPREGS[3]=EXPREGS[4]=0; - EXPREGS[5]++; - EXPREGS[5] &= 7; - MMC3RegReset(); +static void M45Reset(void) { + EXPREGS[0] = EXPREGS[1] = EXPREGS[2] = EXPREGS[3] = EXPREGS[4] = 0; + EXPREGS[5]++; + EXPREGS[5] &= 7; + MMC3RegReset(); } -static void M45Power(void) -{ - setchr8(0); - GenMMC3Power(); - EXPREGS[0]=EXPREGS[1]=EXPREGS[2]=EXPREGS[3]=EXPREGS[4]=EXPREGS[5]=0; - SetWriteHandler(0x5000,0x7FFF,M45Write); - SetReadHandler(0x5000,0x5FFF,M45Read); +static void M45Power(void) { + setchr8(0); + GenMMC3Power(); + EXPREGS[0] = EXPREGS[1] = EXPREGS[2] = EXPREGS[3] = EXPREGS[4] = EXPREGS[5] = 0; + SetWriteHandler(0x5000, 0x7FFF, M45Write); + SetReadHandler(0x5000, 0x5FFF, M45Read); } -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"); +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 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 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 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); +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, 0); - pwrap=M47PW; - cwrap=M47CW; - info->Power=M47Power; - AddExState(EXPREGS, 1, 0, "EXPR"); +void Mapper47_Init(CartInfo *info) { + GenMMC3_Init(info, 512, 256, 8, 0); + 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 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 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 DECLFW(M49Write) { + if (A001B & 0x80) { + EXPREGS[0] = V; + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); + } } -static void M49Reset(void) -{ - EXPREGS[0]=0; - MMC3RegReset(); +static void M49Reset(void) { + EXPREGS[0] = 0; + MMC3RegReset(); } -static void M49Power(void) -{ - M49Reset(); - GenMMC3Power(); - SetWriteHandler(0x6000,0x7FFF,M49Write); - SetReadHandler(0x6000,0x7FFF,0); +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"); +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 mask = 0x1F^((EXPREGS[0]&8)<<1); - uint32 bank = ((EXPREGS[0]&6)|((EXPREGS[0]>>3)&EXPREGS[0]&1))<<4; - setprg8(A, bank|(V & mask)); +static void M52PW(uint32 A, uint8 V) { + uint32 mask = 0x1F ^ ((EXPREGS[0] & 8) << 1); + uint32 bank = ((EXPREGS[0] & 6) | ((EXPREGS[0] >> 3) & EXPREGS[0] & 1)) << 4; + setprg8(A, bank | (V & mask)); } -static void M52CW(uint32 A, uint8 V) -{ - uint32 mask = 0xFF^((EXPREGS[0]&0x40)<<1); -// uint32 bank = (((EXPREGS[0]>>3)&4)|((EXPREGS[0]>>1)&2)|((EXPREGS[0]>>6)&(EXPREGS[0]>>4)&1))<<7; - uint32 bank = (((EXPREGS[0]>>4)&2)|(EXPREGS[0]&4)|((EXPREGS[0]>>6)&(EXPREGS[0]>>4)&1))<<7; // actually 256K CHR banks index bits is inverted! - setchr1(A, bank|(V & mask)); +static void M52CW(uint32 A, uint8 V) { + uint32 mask = 0xFF ^ ((EXPREGS[0] & 0x40) << 1); +// uint32 bank = (((EXPREGS[0]>>3)&4)|((EXPREGS[0]>>1)&2)|((EXPREGS[0]>>6)&(EXPREGS[0]>>4)&1))<<7; + uint32 bank = (((EXPREGS[0] >> 4) & 2) | (EXPREGS[0] & 4) | ((EXPREGS[0] >> 6) & (EXPREGS[0] >> 4) & 1)) << 7; // actually 256K CHR banks index bits is inverted! + setchr1(A, bank | (V & mask)); } -static DECLFW(M52Write) -{ - if(EXPREGS[1]) - { - WRAM[A-0x6000]=V; - return; - } - EXPREGS[1]=V&0x80; - EXPREGS[0]=V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); +static DECLFW(M52Write) { + if (EXPREGS[1]) { + WRAM[A - 0x6000] = V; + return; + } + EXPREGS[1] = V & 0x80; + EXPREGS[0] = V; + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); } -static void M52Reset(void) -{ - EXPREGS[0]=EXPREGS[1]=0; - MMC3RegReset(); +static void M52Reset(void) { + EXPREGS[0] = EXPREGS[1] = 0; + MMC3RegReset(); } -static void M52Power(void) -{ - M52Reset(); - GenMMC3Power(); - SetWriteHandler(0x6000,0x7FFF,M52Write); +static void M52Power(void) { + M52Reset(); + GenMMC3Power(); + SetWriteHandler(0x6000, 0x7FFF, M52Write); } -void Mapper52_Init(CartInfo *info) -{ - GenMMC3_Init(info, 256, 256, 8, info->battery); - cwrap=M52CW; - pwrap=M52PW; - info->Reset=M52Reset; - info->Power=M52Power; - AddExState(EXPREGS, 2, 0, "EXPR"); +void Mapper52_Init(CartInfo *info) { + GenMMC3_Init(info, 256, 256, 8, info->battery); + cwrap = M52CW; + pwrap = M52PW; + info->Reset = M52Reset; + info->Power = M52Power; + AddExState(EXPREGS, 2, 0, "EXPR"); +} + +// ---------------------------- Mapper 76 ------------------------------- + +static void M76CW(uint32 A, uint8 V) { + if (A >= 0x1000) + setchr2((A & 0xC00) << 1, V); +} + +void Mapper76_Init(CartInfo *info) { + GenMMC3_Init(info, 128, 128, 0, 0); + cwrap = M76CW; } // ---------------------------- Mapper 74 ------------------------------- -static void M74CW(uint32 A, uint8 V) -{ - //printf("%04X = %02X\n",A,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); +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"); +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}; +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 void M114PWRAP(uint32 A, uint8 V) { + if (EXPREGS[0] & 0x80) { +// FCEU_printf("8000-C000:%02X\n",EXPREGS[0]&0xF); + setprg16(0x8000, EXPREGS[0] & 0xF); + setprg16(0xC000, EXPREGS[0] & 0xF); + } else { +// FCEU_printf("%04X:%02X\n",A,V&0x3F); + setprg8(A, V & 0x3F); + } } -static DECLFW(M114Write) -{ - switch(A&0xE001) - { - case 0x8001: MMC3_CMDWrite(0xA000,V); 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; - case 0xA001: IRQLatch=V; break; - case 0xC001: IRQReload=1; break; - case 0xE000: X6502_IRQEnd(FCEU_IQEXT);IRQa=0; break; - case 0xE001: IRQa=1; break; - } +static DECLFW(M114Write) { + switch (A & 0xE001) { + case 0x8001: MMC3_CMDWrite(0xA000, V); 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; + case 0xA001: IRQLatch = V; break; + case 0xC001: IRQReload = 1; break; + case 0xE000: X6502_IRQEnd(FCEU_IQEXT); IRQa = 0; break; + case 0xE001: IRQa = 1; break; + } } -static DECLFW(M114ExWrite) -{ - if(A<=0x7FFF) - { - EXPREGS[0]=V; - FixMMC3PRG(MMC3_cmd); - } +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 M114Power(void) { + GenMMC3Power(); + SetWriteHandler(0x8000, 0xFFFF, M114Write); + SetWriteHandler(0x5000, 0x7FFF, M114ExWrite); } -static void M114Reset(void) -{ - EXPREGS[0]=0; - MMC3RegReset(); +static void M114Reset(void) { + EXPREGS[0] = 0; + MMC3RegReset(); } -void Mapper114_Init(CartInfo *info) -{ - isRevB=0; - GenMMC3_Init(info, 256, 256, 0, 0); - pwrap=M114PWRAP; - info->Power=M114Power; - info->Reset=M114Reset; - AddExState(EXPREGS, 1, 0, "EXPR"); - AddExState(&cmdin, 1, 0, "CMDI"); +void Mapper114_Init(CartInfo *info) { + isRevB = 0; + GenMMC3_Init(info, 256, 256, 0, 0); + pwrap = M114PWRAP; + info->Power = M114Power; + info->Reset = M114Reset; + AddExState(EXPREGS, 1, 0, "EXPR"); + AddExState(&cmdin, 1, 0, "CMDI"); } // ---------------------------- Mapper 115 KN-658 board ------------------------------ -static void M115PW(uint32 A, uint8 V) -{ +static void M115PW(uint32 A, uint8 V) { //zero 09-apr-2012 - #3515357 - changed to support Bao Qing Tian (mapper 248) which was missing BG gfx. 115 game(s?) seem still to work OK. - GENPWRAP(A,V); - if(A==0x8000 && EXPREGS[0]&0x80) - setprg16(0x8000,(EXPREGS[0]&0xF)); + setprg8(A, V); + if (A == 0x8000 && EXPREGS[0] & 0x80) + setprg16(0x8000, (EXPREGS[0] & 0xF)); } -static void M115CW(uint32 A, uint8 V) -{ - setchr1(A,(uint32)V|((EXPREGS[1]&1)<<8)); +static void M115CW(uint32 A, uint8 V) { + setchr1(A, (uint32)V | ((EXPREGS[1] & 1) << 8)); } -static DECLFW(M115Write) -{ -// FCEU_printf("%04x:%04x\n",A,V); - if(A==0x5080) EXPREGS[2]=V; - if(A==0x6000) - EXPREGS[0]=V; - else if(A==0x6001) - EXPREGS[1]=V; - FixMMC3PRG(MMC3_cmd); +static DECLFW(M115Write) { +// FCEU_printf("%04x:%04x\n",A,V); + if (A == 0x5080) EXPREGS[2] = V; + if (A == 0x6000) + EXPREGS[0] = V; + else if (A == 0x6001) + EXPREGS[1] = V; + FixMMC3PRG(MMC3_cmd); } -static DECLFR(M115Read) -{ - return EXPREGS[2]; +static DECLFR(M115Read) { + return EXPREGS[2]; } -static void M115Power(void) -{ - GenMMC3Power(); - SetWriteHandler(0x4100,0x7FFF,M115Write); - SetReadHandler(0x5000,0x5FFF,M115Read); +static void M115Power(void) { + GenMMC3Power(); + SetWriteHandler(0x4100, 0x7FFF, M115Write); + SetReadHandler(0x5000, 0x5FFF, M115Read); } -void Mapper115_Init(CartInfo *info) -{ - GenMMC3_Init(info, 128, 512, 0, 0); - cwrap=M115CW; - pwrap=M115PW; - info->Power=M115Power; - AddExState(EXPREGS, 2, 0, "EXPR"); +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 118 ------------------------------ @@ -868,248 +776,217 @@ void Mapper115_Init(CartInfo *info) static uint8 PPUCHRBus; static uint8 TKSMIR[8]; -static void TKSPPU(uint32 A) -{ - A&=0x1FFF; - A>>=10; - PPUCHRBus=A; - setmirror(MI_0+TKSMIR[A]); +static void 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)); +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)); } // ---------------------------- Mapper 119 ------------------------------ -static void TQWRAP(uint32 A, uint8 V) -{ - setchr1r((V&0x40)>>2,A,V&0x3F); +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); +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 134 ------------------------------ -static void M134PW(uint32 A, uint8 V) -{ - setprg8(A,(V&0x1F)|((EXPREGS[0]&2)<<4)); +static void M134PW(uint32 A, uint8 V) { + setprg8(A, (V & 0x1F) | ((EXPREGS[0] & 2) << 4)); } -static void M134CW(uint32 A, uint8 V) -{ - setchr1(A,(V&0xFF)|((EXPREGS[0]&0x20)<<3)); +static void M134CW(uint32 A, uint8 V) { + setchr1(A, (V & 0xFF) | ((EXPREGS[0] & 0x20) << 3)); } -static DECLFW(M134Write) -{ - EXPREGS[0]=V; - FixMMC3CHR(MMC3_cmd); - FixMMC3PRG(MMC3_cmd); +static DECLFW(M134Write) { + EXPREGS[0] = V; + FixMMC3CHR(MMC3_cmd); + FixMMC3PRG(MMC3_cmd); } -static void M134Power(void) -{ - EXPREGS[0]=0; - GenMMC3Power(); - SetWriteHandler(0x6001,0x6001,M134Write); +static void M134Power(void) { + EXPREGS[0] = 0; + GenMMC3Power(); + SetWriteHandler(0x6001, 0x6001, M134Write); } -static void M134Reset(void) -{ - EXPREGS[0]=0; - MMC3RegReset(); +static void M134Reset(void) { + EXPREGS[0] = 0; + MMC3RegReset(); } -void Mapper134_Init(CartInfo *info) -{ - GenMMC3_Init(info, 256, 256, 0, 0); - pwrap=M134PW; - cwrap=M134CW; - info->Power=M134Power; - info->Reset=M134Reset; - AddExState(EXPREGS, 4, 0, "EXPR"); +void Mapper134_Init(CartInfo *info) { + GenMMC3_Init(info, 256, 256, 0, 0); + pwrap = M134PW; + cwrap = M134CW; + info->Power = M134Power; + info->Reset = M134Reset; + AddExState(EXPREGS, 4, 0, "EXPR"); } // ---------------------------- Mapper 165 ------------------------------ -static void M165CW(uint32 A, uint8 V) -{ - if(V==0) - setchr4r(0x10,A,0); - else - setchr4(A,V>>2); +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 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 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 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 M165PPU(uint32 A) -{ - if((A&0x1FF0)==0x1FD0) - { - EXPREGS[0]=0xFD; - M165PPUFD(); - } else if((A&0x1FF0)==0x1FE0) - { - EXPREGS[0]=0xFE; - M165PPUFE(); - } +static void 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(); +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"); +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 191 ------------------------------ -static void M191CW(uint32 A, uint8 V) -{ - setchr1r((V&0x80)>>3,A,V); +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"); +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) -{ - //Ying Lie Qun Xia Zhuan (Chinese), - //You Ling Xing Dong (China) (Unl) [this will be mistakenly headered as m074 sometimes] - if((V==8)||(V==9)||(V==0xA)||(V==0xB)) - setchr1r(0x10,A,V); - else - setchr1r(0,A,V); +static void M192CW(uint32 A, uint8 V) { + //Ying Lie Qun Xia Zhuan (Chinese), + //You Ling Xing Dong (China) (Unl) [this will be mistakenly headered as m074 sometimes] + if ((V == 8) || (V == 9) || (V == 0xA) || (V == 0xB)) + 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"); +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); +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"); +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 195 ------------------------------- static uint8 *wramtw; static uint16 wramsize; -static void M195CW(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 M195CW(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 M195Power(void) -{ - GenMMC3Power(); - setprg4r(0x10,0x5000,0); - SetWriteHandler(0x5000,0x5fff,CartBW); - SetReadHandler(0x5000,0x5fff,CartBR); +static void M195Power(void) { + GenMMC3Power(); + setprg4r(0x10, 0x5000, 0); + SetWriteHandler(0x5000, 0x5fff, CartBW); + SetReadHandler(0x5000, 0x5fff, CartBR); } -static void M195Close(void) -{ - if(wramtw) - FCEU_gfree(wramtw); - wramtw=NULL; +static void M195Close(void) { + if (wramtw) + FCEU_gfree(wramtw); + wramtw = NULL; } -void Mapper195_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M195CW; - info->Power=M195Power; - info->Close=M195Close; - 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, "TRAM"); +void Mapper195_Init(CartInfo *info) { + GenMMC3_Init(info, 512, 256, 8, info->battery); + cwrap = M195CW; + info->Power = M195Power; + info->Close = M195Close; + 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, "TRAM"); } // ---------------------------- Mapper 196 ------------------------------- @@ -1118,346 +995,308 @@ void Mapper195_Init(CartInfo *info) // CMD address line, Mali Boss additionally check if wiring are correct for // game -static void M196PW(uint32 A, uint8 V) -{ - if(EXPREGS[0]) // Tenchi o Kurau II - Shokatsu Koumei Den (J) (C).nes - setprg32(0x8000,EXPREGS[1]); - else - setprg8(A,V); -// setprg8(A,(V&3)|((V&8)>>1)|((V&4)<<1)); // Mali Splash Bomb +static void M196PW(uint32 A, uint8 V) { + if (EXPREGS[0]) // Tenchi o Kurau II - Shokatsu Koumei Den (J) (C).nes + setprg32(0x8000, EXPREGS[1]); + else + setprg8(A, V); +// setprg8(A,(V&3)|((V&8)>>1)|((V&4)<<1)); // Mali Splash Bomb } //static void M196CW(uint32 A, uint8 V) //{ -// setchr1(A,(V&0xDD)|((V&0x20)>>4)|((V&2)<<4)); +// setchr1(A,(V&0xDD)|((V&0x20)>>4)|((V&2)<<4)); //} -static DECLFW(Mapper196Write) -{ - if(A >= 0xC000) { - A=(A&0xFFFE)|((A>>2)&1)|((A>>3)&1); - MMC3_IRQWrite(A,V); - } - else { - A=(A&0xFFFE)|((A>>2)&1)|((A>>3)&1)|((A>>1)&1); -// A=(A&0xFFFE)|((A>>3)&1); // Mali Splash Bomb - MMC3_CMDWrite(A,V); - } +static DECLFW(Mapper196Write) { + if (A >= 0xC000) { + A = (A & 0xFFFE) | ((A >> 2) & 1) | ((A >> 3) & 1); + MMC3_IRQWrite(A, V); + } else { + A = (A & 0xFFFE) | ((A >> 2) & 1) | ((A >> 3) & 1) | ((A >> 1) & 1); +// A=(A&0xFFFE)|((A>>3)&1); // Mali Splash Bomb + MMC3_CMDWrite(A, V); + } } -static DECLFW(Mapper196WriteLo) -{ - EXPREGS[0]=1; - EXPREGS[1]=(V&0xf)|(V>>4); - FixMMC3PRG(MMC3_cmd); +static DECLFW(Mapper196WriteLo) { + EXPREGS[0] = 1; + EXPREGS[1] = (V & 0xf) | (V >> 4); + FixMMC3PRG(MMC3_cmd); } -static void Mapper196Power(void) -{ - GenMMC3Power(); - EXPREGS[0] = EXPREGS[1] = 0; - SetWriteHandler(0x6000,0x6FFF,Mapper196WriteLo); - SetWriteHandler(0x8000,0xFFFF,Mapper196Write); +static void Mapper196Power(void) { + GenMMC3Power(); + EXPREGS[0] = EXPREGS[1] = 0; + SetWriteHandler(0x6000, 0x6FFF, Mapper196WriteLo); + SetWriteHandler(0x8000, 0xFFFF, Mapper196Write); } -void Mapper196_Init(CartInfo *info) -{ - GenMMC3_Init(info, 128, 128, 0, 0); - pwrap=M196PW; -// cwrap=M196CW; // Mali Splash Bomb - info->Power=Mapper196Power; +void Mapper196_Init(CartInfo *info) { + GenMMC3_Init(info, 128, 128, 0, 0); + pwrap = M196PW; +// cwrap=M196CW; // Mali Splash Bomb + info->Power = Mapper196Power; } // ---------------------------- Mapper 197 ------------------------------- -static void M197CW(uint32 A, uint8 V) -{ - if(A==0x0000) - setchr4(0x0000,V>>1); - else if(A==0x1000) - setchr2(0x1000,V); - else if(A==0x1400) - setchr2(0x1800,V); +static void M197CW(uint32 A, uint8 V) { + if (A == 0x0000) + setchr4(0x0000, V >> 1); + else if (A == 0x1000) + setchr2(0x1000, V); + else if (A == 0x1400) + setchr2(0x1800, V); } -void Mapper197_Init(CartInfo *info) -{ - GenMMC3_Init(info, 128, 512, 8, 0); - cwrap=M197CW; +void Mapper197_Init(CartInfo *info) { + GenMMC3_Init(info, 128, 512, 8, 0); + cwrap = M197CW; } // ---------------------------- Mapper 198 ------------------------------- -static void M198PW(uint32 A, uint8 V) -{ - if(V>=0x50) // Tenchi o Kurau II - Shokatsu Koumei Den (J) (C).nes - setprg8(A,V&0x4F); - else - setprg8(A,V); +static void M198PW(uint32 A, uint8 V) { + if (V >= 0x50) // Tenchi o Kurau II - Shokatsu Koumei Den (J) (C).nes + setprg8(A, V & 0x4F); + else + setprg8(A, V); } -void Mapper198_Init(CartInfo *info) -{ - GenMMC3_Init(info, 1024, 256, 8, info->battery); - pwrap=M198PW; - info->Power=M195Power; - info->Close=M195Close; - wramsize=4096; - wramtw=(uint8*)FCEU_gmalloc(wramsize); - SetupCartPRGMapping(0x10, wramtw, wramsize, 1); - AddExState(wramtw, wramsize, 0, "TRAM"); +void Mapper198_Init(CartInfo *info) { + GenMMC3_Init(info, 1024, 256, 8, info->battery); + pwrap = M198PW; + info->Power = M195Power; + info->Close = M195Close; + wramsize = 4096; + wramtw = (uint8*)FCEU_gmalloc(wramsize); + SetupCartPRGMapping(0x10, wramtw, wramsize, 1); + AddExState(wramtw, wramsize, 0, "TRAM"); } // ---------------------------- Mapper 205 ------------------------------ // GN-45 BOARD -static void M205PW(uint32 A, uint8 V) -{ +static void M205PW(uint32 A, uint8 V) { // GN-30A - íà÷àëüíàÿ ìàñêà äîëæíà áûòü 1F + àïïàðàòíûé ïåðåêëþ÷àòåëü íà øèíå àäðåñà - setprg8(A,(V&0x0f)|EXPREGS[0]); + setprg8(A, (V & 0x0f) | EXPREGS[0]); } -static void M205CW(uint32 A, uint8 V) -{ +static void M205CW(uint32 A, uint8 V) { // GN-30A - íà÷àëüíàÿ ìàñêà äîëæíà áûòü FF - setchr1(A,(V&0x7F)|(EXPREGS[0]<<3)); + setchr1(A, (V & 0x7F) | (EXPREGS[0] << 3)); } -static DECLFW(M205Write) -{ - if(EXPREGS[2] == 0) { - EXPREGS[0] = A & 0x30; - EXPREGS[2] = A & 0x80; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); - } - else - CartBW(A,V); +static DECLFW(M205Write0) { + if (EXPREGS[2] == 0) { + EXPREGS[0] = A & 0x30; + EXPREGS[2] = A & 0x80; + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); + } else + CartBW(A, V); } -static void M205Reset(void) -{ - EXPREGS[0]=EXPREGS[2]=0; - MMC3RegReset(); +static DECLFW(M205Write1) { + if (EXPREGS[2] == 0) { + EXPREGS[0] = V & 0x30; + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); + } else + CartBW(A, V); } -static void M205Power(void) -{ - GenMMC3Power(); - SetWriteHandler(0x6000,0x6fff,M205Write); +static void M205Reset(void) { + EXPREGS[0] = EXPREGS[2] = 0; + MMC3RegReset(); } -void Mapper205_Init(CartInfo *info) -{ - GenMMC3_Init(info, 256, 256, 8, 0); - pwrap=M205PW; - cwrap=M205CW; - info->Power=M205Power; - info->Reset=M205Reset; - AddExState(EXPREGS, 1, 0, "EXPR"); +static void M205Power(void) { + GenMMC3Power(); + SetWriteHandler(0x6000, 0x6fff, M205Write0); + SetWriteHandler(0x7000, 0x7fff, M205Write1); // OK-411 boards, the same logic, but data latched, 2-in-1 frankenstein +} + +void Mapper205_Init(CartInfo *info) { + GenMMC3_Init(info, 128, 128, 8, 0); + pwrap = M205PW; + cwrap = M205CW; + info->Power = M205Power; + info->Reset = M205Reset; + AddExState(EXPREGS, 1, 0, "EXPR"); } // ---------------------------- Mapper 245 ------------------------------ -static void M245CW(uint32 A, uint8 V) -{ - if(!UNIFchrrama) // Yong Zhe Dou E Long - Dragon Quest VI (As).nes NEEDS THIS for RAM cart - setchr1(A,V&7); - EXPREGS[0]=V; - FixMMC3PRG(MMC3_cmd); +static void M245CW(uint32 A, uint8 V) { + if (!UNIFchrrama) // Yong Zhe Dou E Long - Dragon Quest VI (As).nes NEEDS THIS for RAM cart + 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 M245PW(uint32 A, uint8 V) { + setprg8(A, (V & 0x3F) | ((EXPREGS[0] & 2) << 5)); } -static void M245Power(void) -{ - EXPREGS[0]=0; - GenMMC3Power(); +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"); +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 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 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 DECLFW(M249Write) { + EXPREGS[0] = V; + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); } -static void M249Power(void) -{ - EXPREGS[0]=0; - GenMMC3Power(); - SetWriteHandler(0x5000,0x5000,M249Write); +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"); +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(M250Write) { + MMC3_CMDWrite((A & 0xE000) | ((A & 0x400) >> 10), A & 0xFF); } -static DECLFW(M250IRQWrite) -{ - MMC3_IRQWrite((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); +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; +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 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 DECLFW(M254Write) { + switch (A) { + case 0x8000: EXPREGS[0] = 0xff; break; + case 0xA001: EXPREGS[1] = V; break; + } + MMC3_CMDWrite(A, V); } -static void M254_Power(void) -{ - GenMMC3Power(); - SetWriteHandler(0x8000,0xBFFF,M254Write); - SetReadHandler(0x6000,0x7FFF,MR254WRAM); +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"); +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 TBROM_Init(CartInfo *info) -{ - GenMMC3_Init(info, 64, 64, 0, 0); +void TBROM_Init(CartInfo *info) { + GenMMC3_Init(info, 64, 64, 0, 0); } -void TEROM_Init(CartInfo *info) -{ - GenMMC3_Init(info, 32, 32, 0, 0); +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 TFROM_Init(CartInfo *info) { + GenMMC3_Init(info, 512, 64, 0, 0); } -void TGROM_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 0, 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 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 TLROM_Init(CartInfo *info) { + GenMMC3_Init(info, 512, 256, 0, 0); } -void TSROM_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, 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 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 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 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); +void HKROM_Init(CartInfo *info) { + GenMMC3_Init(info, 512, 512, 1, info->battery); } diff --git a/src/boards/vrc1.cpp b/src/boards/vrc1.cpp new file mode 100644 index 00000000..899bcfb5 --- /dev/null +++ b/src/boards/vrc1.cpp @@ -0,0 +1,70 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2012 CaH4e3 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * VRC-1 + * + */ + +#include "mapinc.h" + +static uint8 preg[3], creg[2], mode; +static SFORMAT StateRegs[] = +{ + { &mode, 1, "MODE" }, + { creg, 2, "CREG" }, + { preg, 3, "PREG" }, + { 0 } +}; + +static void Sync(void) { + setprg8(0x8000, preg[0]); + setprg8(0xA000, preg[1]); + setprg8(0xC000, preg[2]); + setprg8(0xE000, ~0); + setchr4(0x0000, creg[0] | ((mode & 2) << 3)); + setchr4(0x1000, creg[1] | ((mode & 4) << 2)); + setmirror((mode & 1) ^ 1); +} + +static DECLFW(M75Write) { + switch (A & 0xF000) { + case 0x8000: preg[0] = V; Sync(); break; + case 0x9000: mode = V; Sync(); break; + case 0xA000: preg[1] = V; Sync(); break; + case 0xC000: preg[2] = V; Sync(); break; + case 0xE000: creg[0] = V & 0xF; Sync(); break; + case 0xF000: creg[1] = V & 0xF; Sync(); break; + } +} + +static void M75Power(void) { + Sync(); + SetWriteHandler(0x8000, 0xFFFF, M75Write); + SetReadHandler(0x8000, 0xFFFF, CartBR); +} + +static void StateRestore(int version) { + Sync(); +} + +void Mapper75_Init(CartInfo *info) { + info->Power = M75Power; + AddExState(&StateRegs, ~0, 0, 0); + GameStateRestore = StateRestore; +} diff --git a/src/boards/vrc3.cpp b/src/boards/vrc3.cpp new file mode 100644 index 00000000..2ffc8bed --- /dev/null +++ b/src/boards/vrc3.cpp @@ -0,0 +1,134 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2012 CaH4e3 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * VRC-3 + * + */ + +#include "mapinc.h" + +static uint8 preg; +static uint8 IRQx; //autoenable +static uint8 IRQm; //mode +static uint8 IRQa; +static uint16 IRQReload, IRQCount; +static uint8 *WRAM=NULL; +static uint32 WRAMSIZE; + +static SFORMAT StateRegs[] = +{ + { &preg, 1, "PREG" }, + { &IRQa, 1, "IRQA" }, + { &IRQx, 1, "IRQX" }, + { &IRQm, 1, "IRQM" }, + { &IRQReload, 2, "IRQR" }, + { &IRQCount, 2, "IRQC" }, + { 0 } +}; + +static void Sync(void) { + setprg8r(0x10, 0x6000, 0); + setprg16(0x8000, preg); + setprg16(0xC000, ~0); + setchr8(0); +} + +static DECLFW(M73Write) { + switch (A & 0xF000) { + case 0x8000: IRQReload &= 0xFFF0; IRQReload |= (V & 0xF) << 0; break; + case 0x9000: IRQReload &= 0xFF0F; IRQReload |= (V & 0xF) << 4; break; + case 0xA000: IRQReload &= 0xF0FF; IRQReload |= (V & 0xF) << 8; break; + case 0xB000: IRQReload &= 0x0FFF; IRQReload |= (V & 0xF) << 12; break; + case 0xC000: + IRQm = V & 4; + IRQx = V & 1; + IRQa = V & 2; + if (IRQa) { + if (IRQm) { + IRQCount &= 0xFFFF; + IRQCount |= (IRQReload & 0xFF); + } else + IRQCount = IRQReload; + } + X6502_IRQEnd(FCEU_IQEXT); + break; + case 0xD000: X6502_IRQEnd(FCEU_IQEXT); IRQa = IRQx; break; + case 0xF000: preg = V; Sync(); break; + } +} + +static void M73IRQHook(int a) { + uint32 i; + if (!IRQa) return; + for (i = 0; i < a; i++) { + if (IRQm) { + uint16 temp = IRQCount; + temp &= 0xFF; + IRQCount &= 0xFF00; + if (temp == 0xFF) { + IRQCount = IRQReload; + IRQCount |= (uint16)(IRQReload & 0xFF); + X6502_IRQBegin(FCEU_IQEXT); + } else { + temp++; + IRQCount |= temp; + } + } else { + //16 bit mode + if (IRQCount == 0xFFFF) { + IRQCount = IRQReload; + X6502_IRQBegin(FCEU_IQEXT); + } else + IRQCount++; + } + } +} + +static void M73Power(void) { + IRQReload = IRQm = IRQx = 0; + Sync(); + SetReadHandler(0x6000, 0xFFFF, CartBR); + SetWriteHandler(0x6000, 0x7FFF, CartBW); + SetWriteHandler(0x8000, 0xFFFF, M73Write); +} + +static void M73Close(void) +{ + if (WRAM) + FCEU_gfree(WRAM); + WRAM = NULL; +} + +static void StateRestore(int version) { + Sync(); +} + +void Mapper73_Init(CartInfo *info) { + info->Power = M73Power; + info->Close = M73Close; + MapIRQHook = M73IRQHook; + + WRAMSIZE = 8192; + WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); + SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); + AddExState(WRAM, WRAMSIZE, 0, "WRAM"); + + AddExState(&StateRegs, ~0, 0, 0); + GameStateRestore = StateRestore; +} diff --git a/src/fceu.cpp b/src/fceu.cpp index 82afd2c9..b2c5fee5 100644 --- a/src/fceu.cpp +++ b/src/fceu.cpp @@ -1,22 +1,22 @@ /* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ #include #include diff --git a/src/ines-correct.h b/src/ines-correct.h index 7ee2bd67..053cd2de 100644 --- a/src/ines-correct.h +++ b/src/ines-correct.h @@ -5,6 +5,9 @@ {0x82f204ae, -1, 1}, /* Liang Shan Ying Xiong (NJ023) (Ch) [!] */ {0x684afccd, -1, 1}, /* Space Hunter (J) */ {0xad9c63e2, -1, 1}, /* Space Shadow (J) */ + {0xaf5d7aa2, -1, 0}, /* Clu Clu Land */ + {0xcfb224e6, -1, 1}, /* Dragon Ninja (J) [p1][!].nes */ + {0x4f2f1846, -1, 1}, /* Famista '89 - Kaimaku Han!! (J) */ {0xfcdaca80, 0, 0}, /* Elevator Action */ {0xc05a365b, 0, 0}, /* Exed Exes (J) */ {0x32fa246f, 0, 0}, /* Tag Team Pro Wrestling */ @@ -72,9 +75,6 @@ {0xf518dd58, 7, 8}, /* Captain Skyhawk */ {0x84382231, 9, 0}, /* Punch Out (J) */ {0xbe939fce, 9, 1}, /* Punchout*/ - {0xaf5d7aa2, -1, 0}, /* Clu Clu Land */ - {0xcfb224e6, -1, 1}, /* Dragon Ninja (J) [p1][!].nes */ - {0x4f2f1846, -1, 1}, /* Famista '89 - Kaimaku Han!! (J) */ {0x345d3a1a, 11, 1}, /* Castle of Deceit */ {0x5e66eaea, 13, 1}, /* Videomation */ {0xbfc7a2e9, 16, 8}, @@ -87,6 +87,7 @@ {0x5555fca3, 32, 8}, {0x283ad224, 32, 8}, /* Ai Sensei no Oshiete */ {0x243a8735, 32, 0x10|4}, /* Major League */ + {0xbc7b1d0f, 33, -1}, /* Bakushou!! Jinsei Gekijou 2 (J) [!] */ {0xc2730c30, 34, 0}, /* Deadly Towers */ {0x4c7c1af3, 34, 1}, /* Caesar's Palace */ {0x932ff06e, 34, 1}, /* Classic Concentration */ @@ -191,7 +192,7 @@ {0xa9115bc1, 192, -1}, {0x4c7bbb0e, 192, -1}, {0x98c1cd4b, 192, -1}, /* Ying Lie Qun Xia Zhuan (Chinese) */ - {0xee810d55, 192, -1}, /* You Ling Xing Dong (China) (Unl) */ + {0xee810d55, 192, -1}, /* You Ling Xing Dong (Ch) */ {0x442f1a29, 192, -1}, /* Young chivalry */ {0x637134e8, 193, 1}, /* Fighting Hero */ {0xa925226c, 194, -1}, /* Dai-2-Ji - Super Robot Taisen (As) */ @@ -228,21 +229,22 @@ {0xd323b806, 210, 1}, /* Wagyan Land 3 */ {0xbd523011, 210, 2}, /* Dream Master */ {0x5daae69a, 211, -1}, /* Aladdin - Return of Jaffar, The (Unl) [!] */ - {0x046d70cc, 217, -1}, /* 500-in-1 (Anim Splash, Alt Mapper)[p1][!] */ - {0x12f86a4d, 217, -1}, /* 500-in-1 (Static Splash, Alt Mapper)[p1][!] */ - {0xd09f778d, 217, -1}, /* 9999999-in-1 (Static Splash, Alt Mapper)[p1][!] */ + {0x1ec1dfeb, 217, -1}, /* 255-in-1 (Cut version) [p1] */ + {0x046d70cc, 217, -1}, /* 500-in-1 (Anim Splash, Alt Mapper)[p1][!] */ + {0x12f86a4d, 217, -1}, /* 500-in-1 (Static Splash, Alt Mapper)[p1][!] */ + {0xd09f778d, 217, -1}, /* 9999999-in-1 (Static Splash, Alt Mapper)[p1][!] */ {0x62ef6c79, 232, 8}, /* Quattro Sports -Aladdin */ {0x2705eaeb, 234, -1}, /* Maxi 15 */ {0x6f12afc5, 235, -1}, /* Golden Game 150-in-1 */ {0xfb2b6b10, 241, -1}, /* Fan Kong Jing Ying (Ch) */ {0xb5e83c9a, 241, -1}, /* Xing Ji Zheng Ba (Ch) */ - {0x2537b3e6, 241, -1}, /* Dance Xtreme - Prima (Unl) */ - {0x11611e89, 241, -1}, /* Darkseed (Unl) [p1] */ - {0x81a37827, 241, -1}, /* Darkseed (Unl) [p1][b1] */ - {0xc2730c30, 241, -1}, /* Deadly Towers (U) [!] */ - {0x368c19a8, 241, -1}, /* LIKO Study Cartridge 3-in-1 (Unl) [!] */ - {0xa21e675c, 241, -1}, /* Mashou (J) [!] */ - {0x54d98b79, 241, -1}, /* Titanic 1912 (Unl) */ + {0x2537b3e6, 241, -1}, /* Dance Xtreme - Prima (Unl) */ + {0x11611e89, 241, -1}, /* Darkseed (Unl) [p1] */ + {0x81a37827, 241, -1}, /* Darkseed (Unl) [p1][b1] */ + {0xc2730c30, 241, -1}, /* Deadly Towers (U) [!] */ + {0x368c19a8, 241, -1}, /* LIKO Study Cartridge 3-in-1 (Unl) [!] */ + {0xa21e675c, 241, -1}, /* Mashou (J) [!] */ + {0x54d98b79, 241, -1}, /* Titanic 1912 (Unl) */ {0x6bea1235, 245, -1}, /* MMC3 cart, but with nobanking applied to CHR-RAM, so let it be there */ {0x345ee51a, 245, -1}, /* DQ4c */ {0x57514c6c, 245, -1}, /* Yong Zhe Dou E Long - Dragon Quest VI (Ch) */ diff --git a/src/ines.cpp b/src/ines.cpp index 4197585a..c1dca2cb 100644 --- a/src/ines.cpp +++ b/src/ines.cpp @@ -1,23 +1,23 @@ /* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ #include #include @@ -322,55 +322,39 @@ static void CheckHInfo(void) static uint64 savie[]= { - 0x498c10dc463cfe95LL, /* Battle Fleet */ - 0x6917ffcaca2d8466LL, /* Famista '90 */ - - 0xd63dcc68c2b20adcLL, /* Final Fantasy J */ - 0x012df596e2b31174LL, /* Final Fantasy 1+2 */ - 0xf6b359a720549ecdLL, /* Final Fantasy 2 */ - 0x5a30da1d9b4af35dLL, /* Final Fantasy 3 */ - - 0x2ee3417ba8b69706LL, /* Hydlide 3*/ - - 0xebbce5a54cf3ecc0LL, /* Justbreed */ - - 0x6a858da551ba239eLL, /* Kaijuu Monogatari */ - 0xa40666740b7d22feLL, /* Mindseeker */ - - 0x77b811b2760104b9LL, /* Mouryou Senki Madara */ - - 0x11b69122efe86e8cLL, /* RPG Jinsei Game */ - - 0xa70b495314f4d075LL, /* Ys 3 */ - - - 0xc04361e499748382LL, /* AD&D Heroes of the Lance */ - 0xb72ee2337ced5792LL, /* AD&D Hillsfar */ - 0x2b7103b7a27bd72fLL, /* AD&D Pool of Radiance */ - - 0x854d7947a3177f57LL, /* Crystalis */ - - 0xb0bcc02c843c1b79LL, /* DW */ - 0x4a1f5336b86851b6LL, /* DW */ - - 0x2dcf3a98c7937c22LL, /* DW 2 */ - 0x733026b6b72f2470LL, /* Dw 3 */ - 0x98e55e09dfcc7533LL, /* DW 4*/ - 0x8da46db592a1fcf4LL, /* Faria */ - 0x91a6846d3202e3d6LL, /* Final Fantasy */ - 0xedba17a2c4608d20LL, /* "" */ - - 0x94b9484862a26cbaLL, /* Legend of Zelda */ - 0x04a31647de80fdabLL, /* "" */ - - 0x9aa1dc16c05e7de5LL, /* Startropics */ - 0x1b084107d0878bd0LL, /* Startropics 2*/ - - 0x836c0ff4f3e06e45LL, /* Zelda 2 */ - - 0x82000965f04a71bbLL, /* Mirai Shinwa Jarvas */ - - 0 /* Abandon all hope if the game has 0 in the lower 64-bits of its MD5 hash */ + 0xc04361e499748382LL, /* AD&D Heroes of the Lance */ + 0xb72ee2337ced5792LL, /* AD&D Hillsfar */ + 0x2b7103b7a27bd72fLL, /* AD&D Pool of Radiance */ + 0x498c10dc463cfe95LL, /* Battle Fleet */ + 0x854d7947a3177f57LL, /* Crystalis */ + 0x4a1f5336b86851b6LL, /* DW */ + 0xb0bcc02c843c1b79LL, /* DW */ + 0x2dcf3a98c7937c22LL, /* DW 2 */ + 0x98e55e09dfcc7533LL, /* DW 4*/ + 0x733026b6b72f2470LL, /* Dw 3 */ + 0x6917ffcaca2d8466LL, /* Famista '90 */ + 0x8da46db592a1fcf4LL, /* Faria */ + 0xedba17a2c4608d20LL, /* Final Fantasy */ + 0x91a6846d3202e3d6LL, /* Final Fantasy */ + 0x012df596e2b31174LL, /* Final Fantasy 1+2 */ + 0xf6b359a720549ecdLL, /* Final Fantasy 2 */ + 0x5a30da1d9b4af35dLL, /* Final Fantasy 3 */ + 0xd63dcc68c2b20adcLL, /* Final Fantasy J */ + 0x2ee3417ba8b69706LL, /* Hydlide 3*/ + 0xebbce5a54cf3ecc0LL, /* Justbreed */ + 0x6a858da551ba239eLL, /* Kaijuu Monogatari */ + 0x2db8f5d16c10b925LL, /* Kyonshiizu 2 */ + 0x04a31647de80fdabLL, /* Legend of Zelda */ + 0x94b9484862a26cbaLL, /* Legend of Zelda */ + 0xa40666740b7d22feLL, /* Mindseeker */ + 0x82000965f04a71bbLL, /* Mirai Shinwa Jarvas */ + 0x77b811b2760104b9LL, /* Mouryou Senki Madara */ + 0x11b69122efe86e8cLL, /* RPG Jinsei Game */ + 0x9aa1dc16c05e7de5LL, /* Startropics */ + 0x1b084107d0878bd0LL, /* Startropics 2*/ + 0xa70b495314f4d075LL, /* Ys 3 */ + 0x836c0ff4f3e06e45LL, /* Zelda 2 */ + 0 /* Abandon all hope if the game has 0 in the lower 64-bits of its MD5 hash */ }; static struct CHINF moo[]= @@ -551,7 +535,7 @@ static BMAPPINGLocal bmap[] = { {"Konami VRC2/VRC4", 25, Mapper25_Init}, // {"", 26, Mapper26_Init}, // {"", 27, Mapper27_Init}, // Deprecated, dupe for VRC2/VRC4 mapper - {"INL-ROM", 28, Mapper28_Init}, +// {"", 28, Mapper28_Init}, // {"", 29, Mapper29_Init}, // {"", 30, Mapper30_Init}, // {"", 31, Mapper31_Init}, @@ -563,18 +547,18 @@ static BMAPPINGLocal bmap[] = { {"", 37, Mapper37_Init}, {"Bit Corp.", 38, Mapper38_Init}, // Crime Busters // {"", 39, Mapper39_Init}, -// {"", 40, Mapper40_Init}, -// {"", 41, Mapper41_Init}, -// {"", 42, Mapper42_Init}, + {"SMB2j FDS", 40, Mapper40_Init}, + {"CALTRON 6-in-1", 41, Mapper41_Init}, + {"BIO MIRACLE FDS", 42, Mapper42_Init}, {"", 43, Mapper43_Init}, {"", 44, Mapper44_Init}, {"", 45, Mapper45_Init}, -// {"", 46, Mapper46_Init}, + {"RUMBLESTATION 15-in-1",46, Mapper46_Init}, {"", 47, Mapper47_Init}, {"TAITO TCxxx", 48, Mapper48_Init}, {"", 49, Mapper49_Init}, -// {"", 50, Mapper50_Init}, -// {"", 51, Mapper51_Init}, + {"SMB2j FDS REV A", 50, Mapper50_Init}, + {"11-in-1 BALL SERIES", 51, Mapper51_Init}, // 1993 year version {"", 52, Mapper52_Init}, // {"", 53, Mapper53_Init}, // iNES version of complex UNIF board, can't emulate properly as iNES // {"", 54, Mapper54_Init}, @@ -584,8 +568,8 @@ static BMAPPINGLocal bmap[] = { {"", 58, BMCGK192_Init}, {"", 59, Mapper59_Init}, // Check this out {"", 60, BMCD1038_Init}, -// {"", 61, Mapper61_Init}, -// {"", 62, Mapper62_Init}, + {"20-in-1 KAISER REV A", 61, Mapper61_Init}, + {"700-in-1", 62, Mapper62_Init}, // {"", 63, Mapper63_Init}, // {"", 64, Mapper64_Init}, // {"", 65, Mapper65_Init}, @@ -594,16 +578,16 @@ static BMAPPINGLocal bmap[] = { {"Sunsoft Mapper #4", 68, Mapper68_Init}, // {"", 69, Mapper69_Init}, {"", 70, Mapper70_Init}, -// {"", 71, Mapper71_Init}, -// {"", 72, Mapper72_Init}, -// {"", 73, Mapper73_Init}, + {"CAMERICA BF9093", 71, Mapper71_Init}, + {"JALECO JF-17", 72, Mapper72_Init}, + {"KONAMI VRC3", 73, Mapper73_Init}, {"", 74, Mapper74_Init}, -// {"", 75, Mapper75_Init}, -// {"", 76, Mapper76_Init}, -// {"", 77, Mapper77_Init}, + {"KONAMI VRC1", 75, Mapper75_Init}, + {"NAMCOT 108 VER. A", 76, Mapper76_Init}, + {"IREM LROG017", 77, Mapper77_Init}, {"Irem 74HC161/32", 78, Mapper78_Init}, -// {"", 79, Mapper79_Init}, -// {"", 80, Mapper80_Init}, + {"AVE/C&E/TXC BOARD", 79, Mapper79_Init}, + {"TAITO X1-005 VER. A", 80, Mapper80_Init}, // {"", 81, Mapper81_Init}, {"", 82, Mapper82_Init}, {"", 83, Mapper83_Init}, @@ -618,7 +602,7 @@ static BMAPPINGLocal bmap[] = { {"", 92, Mapper92_Init}, {"Sunsoft UNROM", 93, SUNSOFT_UNROM_Init}, {"", 94, Mapper94_Init}, - {"", 95, Mapper95_Init}, + {"NAMCOT 108 VER. B", 95, Mapper95_Init}, {"", 96, Mapper96_Init}, {"", 97, Mapper97_Init}, // {"", 98, Mapper98_Init}, @@ -729,8 +713,8 @@ static BMAPPINGLocal bmap[] = { {"", 203, Mapper203_Init}, {"", 204, Mapper204_Init}, {"", 205, Mapper205_Init}, - {"DEIROM", 206, DEIROM_Init}, -// {"", 207, Mapper207_Init}, + {"NAMCOT 108 VER. C", 206, Mapper206_Init}, // Deprecated, Used to be "DEIROM" whatever it means, but actually simple version of MMC3 + {"TAITO X1-005 VER. B", 207, Mapper207_Init}, {"", 208, Mapper208_Init}, {"", 209, Mapper209_Init}, {"", 210, Mapper210_Init}, @@ -816,22 +800,22 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode) // ROM_size = head.ROM_size; VROM_size = head.VROM_size; - int round = true; - for (int i = 0; i != sizeof(not_power2)/sizeof(not_power2[0]); ++i) - { - //for games not to the power of 2, so we just read enough - //prg rom from it, but we have to keep ROM_size to the power of 2 - //since PRGCartMapping wants ROM_size to be to the power of 2 - //so instead if not to power of 2, we just use head.ROM_size when - //we use FCEU_read - if (not_power2[i] == MapperNo) - { - round = false; - break; - } - } + int round = true; + for (int i = 0; i != sizeof(not_power2)/sizeof(not_power2[0]); ++i) + { + //for games not to the power of 2, so we just read enough + //prg rom from it, but we have to keep ROM_size to the power of 2 + //since PRGCartMapping wants ROM_size to be to the power of 2 + //so instead if not to power of 2, we just use head.ROM_size when + //we use FCEU_read + if (not_power2[i] == MapperNo) + { + round = false; + break; + } + } - if(VROM_size) + if(VROM_size) VROM_size=uppow2(VROM_size); @@ -860,9 +844,9 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode) ResetExState(0,0); SetupCartPRGMapping(0,ROM,ROM_size*0x4000,0); - // SetupCartPRGMapping(1,WRAM,8192,1); +// SetupCartPRGMapping(1,WRAM,8192,1); - FCEU_fread(ROM,0x4000,(round) ? ROM_size : head.ROM_size,fp); + FCEU_fread(ROM,0x4000,(round) ? ROM_size : head.ROM_size,fp); if(VROM_size) FCEU_fread(VROM,0x2000,head.VROM_size,fp); @@ -883,7 +867,7 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode) iNESCart.CRC32=iNESGameCRC32; FCEU_printf(" PRG ROM: %3d x 16KiB\n CHR ROM: %3d x 8KiB\n ROM CRC32: 0x%08lx\n", - (round) ? ROM_size : head.ROM_size, head.VROM_size,iNESGameCRC32); + (round) ? ROM_size : head.ROM_size, head.VROM_size,iNESGameCRC32); { int x; @@ -908,7 +892,7 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode) FCEU_printf(" Battery-backed: %s\n", (head.ROM_type&2)?"Yes":"No"); FCEU_printf(" Trained: %s\n", (head.ROM_type&4)?"Yes":"No"); - // (head.ROM_type&8) = Mirroring: None(Four-screen) +// (head.ROM_type&8) = Mirroring: None(Four-screen) SetInput(); CheckHInfo(); @@ -939,12 +923,12 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode) iNESCart.battery=(head.ROM_type&2)?1:0; iNESCart.mirror=Mirroring; - //if(MapperNo != 18) { - // if(ROM) free(ROM); - // if(VROM) free(VROM); - // ROM=VROM=0; - // return(0); - // } +// if(MapperNo != 18) { +// if(ROM) free(ROM); +// if(VROM) free(VROM); +// ROM=VROM=0; +// return(0); +// } GameInfo->mappernum = MapperNo; @@ -981,7 +965,7 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode) } -//bbit edited: the whole function below was added +// bbit edited: the whole function below was added int iNesSave(){ FILE *fp; char name[2048]; @@ -1210,18 +1194,18 @@ void (*MapInitTab[256])(void)= 0, 0, 0, - Mapper40_init, - Mapper41_init, - Mapper42_init, + 0, //Mapper40_init, + 0, //Mapper41_init, + 0, //Mapper42_init, 0, //Mapper43_init, 0, 0, - Mapper46_init, + 0, //Mapper46_init, 0, 0, //Mapper48_init, 0, - Mapper50_init, - Mapper51_init, + 0, //Mapper50_init, + 0, //Mapper51_init, 0, 0, 0, @@ -1231,8 +1215,8 @@ void (*MapInitTab[256])(void)= 0, //Mapper58_init, 0, //Mapper59_init, 0, //Mapper60_init, - Mapper61_init, - Mapper62_init, + 0, //Mapper61_init, + 0, //Mapper62_init, 0, Mapper64_init, Mapper65_init, @@ -1241,16 +1225,16 @@ void (*MapInitTab[256])(void)= 0, //Mapper68_init, Mapper69_init, 0, //Mapper70_init, - Mapper71_init, - Mapper72_init, - Mapper73_init, + 0, //Mapper71_init, + 0, //Mapper72_init, + 0, //Mapper73_init, 0, - Mapper75_init, - Mapper76_init, - Mapper77_init, + 0, //Mapper75_init, + 0, //Mapper76_init, + 0, //Mapper77_init, 0, //Mapper78_init, - Mapper79_init, - Mapper80_init, + 0, //Mapper79_init, + 0, //Mapper80_init, 0, 0, //Mapper82_init, 0, //Mapper83_init, @@ -1377,7 +1361,7 @@ void (*MapInitTab[256])(void)= 0, //Mapper204_init, 0, 0, - Mapper207_init, + 0, //Mapper207_init, 0, 0, 0, diff --git a/src/ines.h b/src/ines.h index 3dc1743e..a3a9f55b 100644 --- a/src/ines.h +++ b/src/ines.h @@ -185,26 +185,26 @@ void Mapper36_init(void); //void Mapper37_init(void); //void Mapper38_init(void); //void Mapper39_init(void); -void Mapper40_init(void); -void Mapper41_init(void); -void Mapper42_init(void); +//void Mapper40_init(void); +//void Mapper41_init(void); +//void Mapper42_init(void); //void Mapper43_init(void); void Mapper44_init(void); void Mapper45_init(void); -void Mapper46_init(void); +//void Mapper46_init(void); void Mapper47_init(void); //void Mapper48_init(void); void Mapper49_init(void); -void Mapper50_init(void); -void Mapper51_init(void); +//void Mapper50_init(void); +//void Mapper51_init(void); void Mapper53_init(void); void Mapper54_init(void); void Mapper55_init(void); void Mapper56_init(void); //void Mapper59_init(void); void Mapper60_init(void); -void Mapper61_init(void); -void Mapper62_init(void); +//void Mapper61_init(void); +//void Mapper62_init(void); void Mapper63_init(void); void Mapper64_init(void); void Mapper65_init(void); @@ -213,16 +213,16 @@ void Mapper67_init(void); //void Mapper68_init(void); void Mapper69_init(void); //void Mapper70_init(void); -void Mapper71_init(void); -void Mapper72_init(void); -void Mapper73_init(void); -void Mapper74_init(void); -void Mapper75_init(void); -void Mapper76_init(void); -void Mapper77_init(void); +//void Mapper71_init(void); +//void Mapper72_init(void); +//void Mapper73_init(void); +//void Mapper74_init(void); +//void Mapper75_init(void); +//void Mapper76_init(void); +//void Mapper77_init(void); //void Mapper78_init(void); -void Mapper79_init(void); -void Mapper80_init(void); +//void Mapper79_init(void); +//void Mapper80_init(void); void Mapper81_init(void); //void Mapper82_init(void); void Mapper83_init(void); @@ -320,7 +320,7 @@ void Mapper199_init(void); //void Mapper202_init(void); //void Mapper203_init(void); //void Mapper204_init(void); -void Mapper207_init(void); +//void Mapper207_init(void); //void Mapper211_init(void); //void Mapper212_init(void); //void Mapper213_init(void); @@ -389,19 +389,35 @@ void Mapper34_Init(CartInfo *); void Mapper36_Init(CartInfo *); void Mapper37_Init(CartInfo *); void Mapper38_Init(CartInfo *); +void Mapper40_Init(CartInfo *); +void Mapper41_Init(CartInfo *); +void Mapper42_Init(CartInfo *); void Mapper43_Init(CartInfo *); void Mapper44_Init(CartInfo *); void Mapper45_Init(CartInfo *); +void Mapper46_Init(CartInfo *); void Mapper47_Init(CartInfo *); void Mapper48_Init(CartInfo *); void Mapper49_Init(CartInfo *); +void Mapper50_Init(CartInfo *); +void Mapper51_Init(CartInfo *); void Mapper52_Init(CartInfo *); void Mapper57_Init(CartInfo *); void Mapper59_Init(CartInfo *); +void Mapper61_Init(CartInfo *); +void Mapper62_Init(CartInfo *); void Mapper68_Init(CartInfo *); void Mapper70_Init(CartInfo *); +void Mapper71_Init(CartInfo *); +void Mapper72_Init(CartInfo *); +void Mapper73_Init(CartInfo *); void Mapper74_Init(CartInfo *); +void Mapper75_Init(CartInfo *); +void Mapper76_Init(CartInfo *); +void Mapper77_Init(CartInfo *); void Mapper78_Init(CartInfo *); +void Mapper79_Init(CartInfo *); +void Mapper80_Init(CartInfo *); void Mapper82_Init(CartInfo *); void Mapper83_Init(CartInfo *); void Mapper86_Init(CartInfo *); @@ -475,8 +491,10 @@ void Mapper200_Init(CartInfo *); void Mapper201_Init(CartInfo *); void Mapper202_Init(CartInfo *); void Mapper203_Init(CartInfo *); -void Mapper205_Init(CartInfo *); void Mapper204_Init(CartInfo *); +void Mapper205_Init(CartInfo *); +void Mapper206_Init(CartInfo *); +void Mapper207_Init(CartInfo *); void Mapper208_Init(CartInfo *); void Mapper209_Init(CartInfo *); void Mapper210_Init(CartInfo *); diff --git a/src/mappers/40.cpp b/src/mappers/40.cpp deleted file mode 100644 index 9cdc24c7..00000000 --- a/src/mappers/40.cpp +++ /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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 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/src/mappers/41.cpp b/src/mappers/41.cpp deleted file mode 100644 index 84aed5d2..00000000 --- a/src/mappers/41.cpp +++ /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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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/src/mappers/42.cpp b/src/mappers/42.cpp deleted file mode 100644 index 10774bd6..00000000 --- a/src/mappers/42.cpp +++ /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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 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/src/mappers/46.cpp b/src/mappers/46.cpp deleted file mode 100644 index 7e1a9079..00000000 --- a/src/mappers/46.cpp +++ /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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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/src/mappers/61.cpp b/src/mappers/61.cpp deleted file mode 100644 index 10b9e6dc..00000000 --- a/src/mappers/61.cpp +++ /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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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/src/mappers/62.cpp b/src/mappers/62.cpp deleted file mode 100644 index 6da991cc..00000000 --- a/src/mappers/62.cpp +++ /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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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/src/mappers/71.cpp b/src/mappers/71.cpp deleted file mode 100644 index 05b46a3b..00000000 --- a/src/mappers/71.cpp +++ /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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - - - -DECLFW(Mapper71_write) -{ -switch(A&0xF000) - { - case 0xF000: - case 0xE000: - case 0xD000: - case 0xC000:ROM_BANK16(0x8000,V);break; - case 0x9000:onemir((V>>3)&2);break; - } -} - -void Mapper71_init(void) -{ -SetWriteHandler(0x4020,0xffff,Mapper71_write); -} - diff --git a/src/mappers/72.cpp b/src/mappers/72.cpp deleted file mode 100644 index 857f8001..00000000 --- a/src/mappers/72.cpp +++ /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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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/src/mappers/73.cpp b/src/mappers/73.cpp deleted file mode 100644 index 638b965b..00000000 --- a/src/mappers/73.cpp +++ /dev/null @@ -1,115 +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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 IRQx; //autoenable -static uint8 IRQm; //mode -static uint16 IRQr; //reload - -static DECLFW(Mapper73_write) -{ - //printf("$%04x:$%02x\n",A,V); - - switch(A&0xF000) - { - case 0x8000: - IRQr&=0xFFF0;IRQr|=(V&0xF); - break; - case 0x9000: - IRQr&=0xFF0F;IRQr|=(V&0xF)<<4; - break; - case 0xa000: - IRQr&=0xF0FF;IRQr|=(V&0xF)<<8; - break; - case 0xb000: - IRQr&=0x0FFF;IRQr|=(V&0xF)<<12; - break; - case 0xc000: - IRQm=V&4; - IRQx=V&1; - IRQa=V&2; - if(IRQa) - { - if(IRQm) - { - IRQCount&=0xFFFF; - IRQCount|=(IRQr&0xFF); - } - else - { - IRQCount=IRQr; - } - } - X6502_IRQEnd(FCEU_IQEXT); - break; - case 0xd000: - X6502_IRQEnd(FCEU_IQEXT); - IRQa=IRQx; - break; - - case 0xf000:ROM_BANK16(0x8000,V);break; - } -} - -static void Mapper73IRQHook(int a) -{ - for(int i=0;i>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/src/mappers/80.cpp b/src/mappers/80.cpp deleted file mode 100644 index 4ea4474b..00000000 --- a/src/mappers/80.cpp +++ /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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint32 lastA; -static int isfu; -static uint8 CCache[8]; - -static void 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,0x7eff,Mapper80_write);// 7f00-7fff battery backed ram inside mapper chip, - // controlled by 7ef8 register, A8 - enable, FF - disable (?) - MapStateRestore=booga; - isfu=0; -} - -void Mapper207_init(void) -{ - Mapper80_init(); - isfu=1; - PPU_hook=Fudou_PPU; -} diff --git a/src/mappers/SConscript b/src/mappers/SConscript index 4368ecbd..80b79860 100644 --- a/src/mappers/SConscript +++ b/src/mappers/SConscript @@ -1,27 +1,10 @@ my_list = Split(""" 24and26.cpp -40.cpp -41.cpp -42.cpp -46.cpp -50.cpp -51.cpp 6.cpp -61.cpp -62.cpp 65.cpp 67.cpp 69.cpp -71.cpp -72.cpp -73.cpp -75.cpp -76.cpp -77.cpp -79.cpp -80.cpp 85.cpp -emu2413.c mmc2and4.cpp """) # diff --git a/src/unif.h b/src/unif.h index ff7d7ef5..d7a838cd 100644 --- a/src/unif.h +++ b/src/unif.h @@ -45,7 +45,6 @@ void BMCT2271_Init(CartInfo *info); void BMCT262_Init(CartInfo *info); void CNROM_Init(CartInfo *info); void CPROM_Init(CartInfo *info); -void DEIROM_Init(CartInfo *info); void DreamTech01_Init(CartInfo *info); void EKROM_Init(CartInfo *info); void ELROM_Init(CartInfo *info); @@ -86,7 +85,7 @@ void SLROM_Init(CartInfo *info); void SNROM_Init(CartInfo *info); void SOROM_Init(CartInfo *info); void SSSNROM_Init(CartInfo *info); -void SUNSOFT_UNROM_Init(CartInfo *info); // "Shanghi" original version mapper +void SUNSOFT_UNROM_Init(CartInfo *info); // "Shanghi" original version mapper void Super24_Init(CartInfo *info); void Supervision16_Init(CartInfo *info); void TBROM_Init(CartInfo *info); diff --git a/vc/vc10_fceux.vcxproj b/vc/vc10_fceux.vcxproj index 6350c546..12011003 100644 --- a/vc/vc10_fceux.vcxproj +++ b/vc/vc10_fceux.vcxproj @@ -256,6 +256,7 @@ + @@ -272,12 +273,25 @@ + + + + + + + + + + + + + @@ -285,7 +299,6 @@ - @@ -307,7 +320,9 @@ + + @@ -324,7 +339,6 @@ - @@ -580,26 +594,10 @@ - - - - - - - - - - - - - - - - $(IntDir)%(Filename)1.obj diff --git a/vc/vc10_fceux.vcxproj.filters b/vc/vc10_fceux.vcxproj.filters index 1ab310a7..378e1913 100644 --- a/vc/vc10_fceux.vcxproj.filters +++ b/vc/vc10_fceux.vcxproj.filters @@ -160,9 +160,6 @@ boards - - boards - boards @@ -196,9 +193,6 @@ boards - - boards - boards @@ -647,33 +641,9 @@ mappers - - mappers - - - mappers - - - mappers - - - mappers - - - mappers - - - mappers - mappers - - mappers - - - mappers - mappers @@ -683,30 +653,6 @@ mappers - - mappers - - - mappers - - - mappers - - - mappers - - - mappers - - - mappers - - - mappers - - - mappers - mappers @@ -967,6 +913,54 @@ boards + + boards + + + boards + + + boards + + + boards + + + boards + + + boards + + + boards + + + boards + + + boards + + + boards + + + boards + + + boards + + + boards + + + boards + + + boards + + + boards +