M227/242/449: Added DIP switch.
This commit is contained in:
@@ -23,12 +23,14 @@
|
|||||||
static uint16 latchAddr;
|
static uint16 latchAddr;
|
||||||
static uint8 latchData;
|
static uint8 latchData;
|
||||||
static uint8 dipswitch;
|
static uint8 dipswitch;
|
||||||
|
static uint8 dipselect;
|
||||||
|
|
||||||
static SFORMAT StateRegs[] =
|
static SFORMAT StateRegs[] =
|
||||||
{
|
{
|
||||||
{ &latchAddr, 2, "ADDR" },
|
{ &latchAddr, 2, "ADDR" },
|
||||||
{ &latchData, 1, "DATA" },
|
{ &latchData, 1, "DATA" },
|
||||||
{ &latchData, 1, "DIPS" },
|
{ &latchData, 1, "DIPS" },
|
||||||
|
{ &dipselect, 1, "DSEL" },
|
||||||
{ 0 }
|
{ 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -58,12 +60,20 @@ static void Mapper449_Sync(void)
|
|||||||
|
|
||||||
static DECLFR(Mapper449_Read)
|
static DECLFR(Mapper449_Read)
|
||||||
{
|
{
|
||||||
|
if (dipselect)
|
||||||
|
return dipswitch &0x3;
|
||||||
|
else
|
||||||
if (latchAddr &0x200)
|
if (latchAddr &0x200)
|
||||||
return CartBR(A | dipswitch);
|
return CartBR(A | dipswitch &0xF);
|
||||||
else
|
else
|
||||||
return CartBR(A);
|
return CartBR(A);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DECLFW(Mapper449_WriteDIPSelect)
|
||||||
|
{
|
||||||
|
dipselect =V &1;
|
||||||
|
}
|
||||||
|
|
||||||
static DECLFW(Mapper449_WriteLatch)
|
static DECLFW(Mapper449_WriteLatch)
|
||||||
{
|
{
|
||||||
latchData =V;
|
latchData =V;
|
||||||
@@ -73,15 +83,16 @@ static DECLFW(Mapper449_WriteLatch)
|
|||||||
|
|
||||||
static void Mapper449_Reset(void)
|
static void Mapper449_Reset(void)
|
||||||
{
|
{
|
||||||
dipswitch =(dipswitch +1) &0xF;
|
dipswitch++;
|
||||||
latchAddr =latchData =0;
|
latchAddr =latchData =0;
|
||||||
Mapper449_Sync();
|
Mapper449_Sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Mapper449_Power(void)
|
static void Mapper449_Power(void)
|
||||||
{
|
{
|
||||||
dipswitch =latchAddr =latchData =0;
|
dipselect =dipswitch =latchAddr =latchData =0;
|
||||||
Mapper449_Sync();
|
Mapper449_Sync();
|
||||||
|
SetWriteHandler(0x6000, 0x7FFF, Mapper449_WriteDIPSelect);
|
||||||
SetWriteHandler(0x8000, 0xFFFF, Mapper449_WriteLatch);
|
SetWriteHandler(0x8000, 0xFFFF, Mapper449_WriteLatch);
|
||||||
SetReadHandler(0x6000, 0x7FFF, CartBR);
|
SetReadHandler(0x6000, 0x7FFF, CartBR);
|
||||||
SetReadHandler(0x8000, 0xFFFF, Mapper449_Read);
|
SetReadHandler(0x8000, 0xFFFF, Mapper449_Read);
|
||||||
|
|||||||
@@ -415,9 +415,25 @@ static void M227Sync(void) {
|
|||||||
setprg8r(0x10, 0x6000, 0);
|
setprg8r(0x10, 0x6000, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DECLFR(M227Read) {
|
||||||
|
if (latche &0x0400)
|
||||||
|
return CartBR(A | dipswitch);
|
||||||
|
else
|
||||||
|
return CartBR(A);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Mapper227_Reset(void) {
|
||||||
|
dipswitch++;
|
||||||
|
dipswitch &= 15;
|
||||||
|
latche = 0;
|
||||||
|
M227Sync();
|
||||||
|
}
|
||||||
|
|
||||||
void Mapper227_Init(CartInfo *info) {
|
void Mapper227_Init(CartInfo *info) {
|
||||||
submapper =info->submapper;
|
submapper =info->submapper;
|
||||||
Latch_Init(info, M227Sync, NULL, 0x0000, 0x8000, 0xFFFF, 1);
|
Latch_Init(info, M227Sync, M227Read, 0x0000, 0x8000, 0xFFFF, info->iNES2 && (info->PRGRamSize || info->PRGRamSaveSize) || info->battery);
|
||||||
|
info->Reset = Mapper227_Reset;
|
||||||
|
AddExState(&dipswitch, 1, 0, "DIPSW");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------ Map 229 ---------------------------*/
|
/*------------------ Map 229 ---------------------------*/
|
||||||
@@ -511,9 +527,25 @@ static void M242Sync(void) {
|
|||||||
setprg8r(0x10, 0x6000, 0);
|
setprg8r(0x10, 0x6000, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DECLFR(M242Read) {
|
||||||
|
if (latche &0x0100)
|
||||||
|
return CartBR(A | dipswitch);
|
||||||
|
else
|
||||||
|
return CartBR(A);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Mapper242_Reset(void) {
|
||||||
|
dipswitch++;
|
||||||
|
dipswitch &= 31;
|
||||||
|
latche = 0;
|
||||||
|
M242Sync();
|
||||||
|
}
|
||||||
|
|
||||||
void Mapper242_Init(CartInfo *info) {
|
void Mapper242_Init(CartInfo *info) {
|
||||||
M242TwoChips = info->PRGRomSize &0x20000 && info->PRGRomSize >0x20000;
|
M242TwoChips = info->PRGRomSize &0x20000 && info->PRGRomSize >0x20000;
|
||||||
Latch_Init(info, M242Sync, NULL, 0x0000, 0x8000, 0xFFFF, 1);
|
Latch_Init(info, M242Sync, M242Read, 0x0000, 0x8000, 0xFFFF, info->iNES2 && (info->PRGRamSize || info->PRGRamSaveSize) || info->battery);
|
||||||
|
info->Reset = Mapper242_Reset;
|
||||||
|
AddExState(&dipswitch, 1, 0, "DIPSW");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------ Map 288 ---------------------------*/
|
/*------------------ Map 288 ---------------------------*/
|
||||||
|
|||||||
Reference in New Issue
Block a user