cleanup and version bum... hmmm (not no mention something else)

This commit is contained in:
CaH4e3 2012-10-21 16:40:04 +00:00
parent 3bab128770
commit 43ee931dec
100 changed files with 1002 additions and 908 deletions

View File

@ -16,101 +16,59 @@
* 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
*
* Actually, all this may be the same mapper with different switcheable banking modes, maybe it's just an subtypes
* of the same one board with various modes locked just like SuperGame boards, based on 215 mapper
*
*/
#include "mapinc.h"
static uint8 cmd, laststrobe, trigger;
static uint8 DRegs[8];
static uint8 laststrobe, trigger;
static uint8 reg[8];
static uint8 *WRAM=NULL;
static uint32 WRAMSIZE;
static void(*WSync)(void);
static SFORMAT StateRegs[]=
{
{&cmd, 1, "CMD"},
{&laststrobe, 1, "STB"},
{&trigger, 1, "TRG"},
{DRegs, 8, "DREG"},
{reg, 8, "REGS"},
{0}
};
static void Sync(void)
{
setprg32(0x8000,(DRegs[0]<<4)|(DRegs[1]&0xF));
setprg8r(0x10,0x6000,0);
setprg32(0x8000,(reg[0]<<4)|(reg[1]&0xF));
setchr8(0);
}
static void StateRestore(int version)
{
Sync();
WSync();
}
static DECLFR(ReadLow)
{
switch (A&0x7700)
{
case 0x5100: return DRegs[2]; break;
case 0x5500: if(trigger)
return DRegs[2];
case 0x5100:
return reg[2]|reg[0]|reg[1]|reg[3]^0xff; break;
case 0x5500:
if(trigger)
return reg[2]|reg[1]; // Lei Dian Huang Bi Ka Qiu Chuan Shuo (NJ046) may broke other games
else
return 0;
}
return 4;
}
static DECLFW(Write)
{
switch (A&0x7300)
{
case 0x5100: DRegs[0]=V; Sync(); break;
case 0x5000: DRegs[1]=V; Sync(); break;
case 0x5300: DRegs[2]=V; break;
}
}
static DECLFW(Write2)
{
if(A==0x5101)
{
if(laststrobe&&!V)
{
trigger^=1;
}
laststrobe=V;
}else if(A==0x5100&&V==6) //damn thoose protected games
setprg32(0x8000,3);
else
switch (A&0x7300)
{
case 0x5200: DRegs[0]=V; Sync(); break;
case 0x5000: DRegs[1]=V; Sync(); if(!(DRegs[1]&0x80)&&(scanline<128)) setchr8(0); break;
case 0x5300: DRegs[2]=V; break;
}
}
static uint8 WRAM[8192];
static DECLFR(AWRAM)
{
return(WRAM[A-0x6000]);
}
static DECLFW(BWRAM)
{
WRAM[A-0x6000]=V;
}
static void Power(void)
{
memset(DRegs,0,8);
DRegs[1]=0xFF;
cmd=0;
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x4020,0x5FFF,Write);
SetReadHandler(0x6000,0x7FFF,AWRAM);
SetWriteHandler(0x6000,0x7FFF,BWRAM);
setchr8(0);
Sync();
}
static void M163HB(void)
{
if(DRegs[1]&0x80)
if(reg[1]&0x80)
{
if(scanline==239)
{
@ -122,39 +80,172 @@ static void M163HB(void)
setchr4(0x0000,1);
setchr4(0x1000,1);
}
/*
if(scanline>=127) // Hu Lu Jin Gang (NJ039) (Ch) [!] don't like it
{
setchr4(0x0000,1);
setchr4(0x1000,1);
}
else
{
setchr4(0x0000,0);
setchr4(0x1000,0);
}
*/
}
}
static void Power2(void)
static DECLFW(Write)
{
memset(DRegs,0,8);
DRegs[1]=0xFF;
laststrobe=1;
cmd=0;
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x4020,0x5FFF,Write2);
SetReadHandler(0x6000,0x7FFF,AWRAM);
SetWriteHandler(0x6000,0x7FFF,BWRAM);
SetReadHandler(0x5000,0x5FFF,ReadLow);
setchr8(0);
Sync();
switch (A&0x7300)
{
case 0x5100: reg[0]=V; WSync(); break;
case 0x5000: reg[1]=V; WSync(); break;
case 0x5300: reg[2]=V; break;
case 0x5200: reg[3]=V; WSync(); break;
}
}
static void Power(void)
{
memset(reg,0,8);
reg[1]=0xFF;
SetWriteHandler(0x5000,0x5FFF,Write);
SetReadHandler(0x6000,0xFFFF,CartBR);
SetWriteHandler(0x6000,0x7FFF,CartBW);
WSync();
}
static void Close(void)
{
if(WRAM)
FCEU_gfree(WRAM);
WRAM=NULL;
}
void Mapper164_Init(CartInfo *info)
{
info->Power=Power;
info->Close=Close;
WSync = Sync;
WRAMSIZE = 8192;
WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);
SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);
AddExState(WRAM, WRAMSIZE, 0, "WRAM");
if(info->battery)
{
info->SaveGame[0]=WRAM;
info->SaveGameLen[0]=WRAMSIZE;
}
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
AddExState(WRAM, 8192, 0, "WRAM");
info->SaveGame[0]=WRAM;
info->SaveGameLen[0]=8192;
}
static DECLFW(Write2)
{
if(A==0x5101)
{
if(laststrobe&&!V)
trigger^=1;
laststrobe=V;
}else if(A==0x5100&&V==6) //damn thoose protected games
setprg32(0x8000,3);
else
switch (A&0x7300)
{
case 0x5200: reg[0]=V; WSync(); break;
case 0x5000: reg[1]=V; WSync(); if(!(reg[1]&0x80)&&(scanline<128)) setchr8(0); /* setchr8(0); */ break;
case 0x5300: reg[2]=V; break;
case 0x5100: reg[3]=V; WSync(); break;
}
}
static void Power2(void)
{
memset(reg,0,8);
laststrobe=1;
SetReadHandler(0x5000,0x5FFF,ReadLow);
SetWriteHandler(0x5000,0x5FFF,Write2);
SetReadHandler(0x6000,0xFFFF,CartBR);
SetWriteHandler(0x6000,0x7FFF,CartBW);
WSync();
}
void Mapper163_Init(CartInfo *info)
{
info->Power=Power2;
info->Close=Close;
WSync = Sync;
GameHBIRQHook=M163HB;
WRAMSIZE = 8192;
WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);
SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);
AddExState(WRAM, WRAMSIZE, 0, "WRAM");
if(info->battery)
{
info->SaveGame[0]=WRAM;
info->SaveGameLen[0]=WRAMSIZE;
}
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}
static void Sync3(void)
{
setchr8(0);
setprg8r(0x10,0x6000,0);
switch(reg[3]&7){
case 0:
case 2: setprg32(0x8000,(reg[0]&0xc)|(reg[1]&2)|((reg[2]&0xf)<<4)); break;
case 1:
case 3: setprg32(0x8000,(reg[0]&0xc)|(reg[2]&0xf)<<4); break;
case 4:
case 6: setprg32(0x8000,(reg[0]&0xe)|((reg[1]>>1)&1)|((reg[2]&0xf)<<4)); break;
case 5:
case 7: setprg32(0x8000,(reg[0]&0xf)|((reg[2]&0xf)<<4)); break;
}
}
static DECLFW(Write3)
{
reg[(A>>8)&3]=V;
WSync();
}
static void Power3(void)
{
reg[0]=3;
reg[1]=0;
reg[2]=0;
reg[3]=7;
SetWriteHandler(0x5000,0x5FFF,Write3);
SetReadHandler(0x6000,0xFFFF,CartBR);
SetWriteHandler(0x6000,0x7FFF,CartBW);
WSync();
}
void UNLFS304_Init(CartInfo *info)
{
info->Power=Power3;
info->Close=Close;
WSync = Sync3;
WRAMSIZE = 8192;
WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);
SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);
AddExState(WRAM, WRAMSIZE, 0, "WRAM");
if(info->battery)
{
info->SaveGame[0]=WRAM;
info->SaveGameLen[0]=WRAMSIZE;
}
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
AddExState(WRAM, 8192, 0, "WRAM");
}

View File

@ -614,6 +614,7 @@ static BMAPPINGLocal bmap[] = {
{"", 156, Mapper156_Init},
{"", 159, Mapper159_Init},
{"SA009", 160, SA009_Init},
{"", 162, UNLFS304_Init},
{"", 163, Mapper163_Init},
{"", 164, Mapper164_Init},
{"", 165, Mapper165_Init},

View File

@ -402,6 +402,7 @@ static BMAPPING bmap[] = {
{ "8157", UNL8157_Init,0},
{ "T-262", BMCT262_Init,0},
{ "FK23C", BMCFK23C_Init,0},
{ "FS304", UNLFS304_Init,0},
{ "A65AS", BMCA65AS_Init,0},
{ "C-N22M", UNLCN22M_Init,0},
{ "EDU2000", UNLEDU2000_Init,0},

View File

@ -100,6 +100,7 @@ void BMCGhostbusters63in1_Init(CartInfo *info);
void BMCBS5_Init(CartInfo *info);
void DreamTech01_Init(CartInfo *info);
void UNLFS304_Init(CartInfo *info);
void Mapper190_Init(CartInfo *info);
void UNLCC21_Init(CartInfo *info);
void UNLCN22M_Init(CartInfo *info);